Found another way which uses a proxy to the engine instead of a proxy
to the session, this is quite easier to inject as you don't have to
replace the session of the app but just change the parameter to
DBSession.configure inside init_model to MultiSiteEngine()
class MultiSiteEngine(object):
def __init__(self):
self.engines = {}
def __getattr__(self, name):
if name == 'engines':
return object.__getattribute__(self, name)
if not self.engines.has_key(config['sqlalchemy.url']):
self.engines[config['sqlalchemy.url']] =
engine_from_config(config, 'sqlalchemy.')
return getattr(self.engines[config['sqlalchemy.url']], name)
Still do not know if there is a better way to solve the problem
without proxying parts of SQLAlchemy.
--
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en.