do not unnecessarily close the database connection (fixes #20)

This commit is contained in:
Jan Dittberner 2009-03-07 12:45:24 +01:00
parent 431519f9e3
commit 72a02a6e95
2 changed files with 2 additions and 5 deletions

View file

@ -11,10 +11,8 @@ from pylons.i18n import _, ungettext, N_, add_fallback, set_lang
from pylons.templating import render
import pyalchemybiz.lib.helpers as h
import pyalchemybiz.model as model
from pyalchemybiz.model import meta
from sqlalchemy.orm import sessionmaker
class BaseController(WSGIController):
@ -31,13 +29,11 @@ class BaseController(WSGIController):
except:
pass
# connect to database
conn = meta.engine.connect()
meta.Session.configure(bind=conn)
try:
return WSGIController.__call__(self, environ, start_response)
finally:
meta.Session.remove()
conn.close()
# Include the '_' function in the public names
__all__ = [__name for __name in locals().keys() if not __name.startswith('_') \

View file

@ -16,6 +16,7 @@ def init_model(engine):
meta.engine = engine
meta.Session = orm.scoped_session(sm)
person.t_person = sa.Table(
'person', meta.metadata, autoload=True, autoload_with=engine)
customer.t_customer = sa.Table(