Refactor connection setup and enhance view initialization with session management

1 parent 61e40e7b
...@@ -286,7 +286,7 @@ class Targets(PCBase, DefaultModel): ...@@ -286,7 +286,7 @@ class Targets(PCBase, DefaultModel):
def get_connection(settings): def get_connection(settings):
url = 'pcpd.url' in settings and settings['pcpd.url'] and 'pcpd.' or 'sqlalchemy.' url = 'pcpd.url' in settings and settings['pcpd.url'] and 'pcpd.' or 'sqlalchemy.'
engine = engine_from_config(settings, url, pool_pre_ping=True) engine = engine_from_config(settings, url)
PCDBSession.configure(bind=engine) PCDBSession.configure(bind=engine)
PCBase.metadata.bind = engine PCBase.metadata.bind = engine
return engine return engine
...@@ -294,7 +294,6 @@ def get_connection(settings): ...@@ -294,7 +294,6 @@ def get_connection(settings):
def includeme(config): def includeme(config):
settings = get_settings() settings = get_settings()
get_connection(settings) get_connection(settings)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!