> Karlo Lozovina escreveu:
>>>
>>> engine = engine_from_config(config, 'sqlalchemy.')
>>> init_model(engine)
>>>
>> I have to add that piece of code to
>> every action of my controllers. That seems somehow redundant to me...
>>
I also was wondering if this was the "right thing to do." I solve it
by putting this in myapp.lib.base :
class BaseController(WSGIController):
def __call__(self, environ, start_response):
model.db.connect(config['sqlalchemy.default.uri'])
try:
return WSGIController.__call__(self, environ, start_response)
finally:
model.db.session.remove()
... where model/db.py is more or less this:
from sqlalchemy import create_engine
from elixir import session, metadata
def connect(dsn):
bind = create_engine(dsn)
session.bind = bind
metadata.bind = bind
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---