Subclass the sqlalchemy.orm.Session providing a get_bind method, then you can pass the class_ parameter to the sessionmaker inside model/__init__.py
Whenever the session is going to be used the get_bind method will be called to ask for the bound engine, so you can implement there any logic to return different engines and so route to multiple databases. On Thu, Jul 26, 2012 at 6:20 PM, Kai H. <[email protected]> wrote: > Hello, > > i'm trying to make my TG2-App be able to handle several projects, i.e. > several database-instances for the same db-model (including user-tables for > authentication). They should be accessed by: > http://localhost:8080/project1 > http://localhost:8080/project2 etc. > > At the moment i have something like this in my development/whatever.ini > > sqlalchemy.project1.url= mysql://foo:bar@host1:3306/project1 > sqlalchemy.project2.url = mysql://foo:bar@host2:3306/project2 > > for project-access in my root-controller i have sth. like > > @expose() > def _lookup(self, project, *remainder): > engine = engine_from_config(pylons_config, 'sqlalchemy.%s.' % project) > app_globals.project = project > DBSession.configure(bind=engine) > project = RootProjectController() > return project, remainder > > That works actually pretty well, except for the authentication > (standard-tg2). And that is my problem. I tried to bend the login-stuff > (like the login_handler) to \project1\login_handler, but i didnt manage to > get it working. > > Do you have any suggestions how to get the login working under > /project/login? > OR do you have any other suggestions for that multi-project-problem? > > Thanks in advance, > Kai > > -- > You received this message because you are subscribed to the Google Groups > "TurboGears" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/turbogears/-/Ci5cJoxDDSIJ. > 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. -- 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.

