On Nov 3, 2011, at 9:28 AM, Tarek Ziadé wrote: > So, > > I have worked on a first prototype, and was unable to use the event > system as-is, because of a lack of context to know which database the > user is trying to access. > > So, after a bit of hacking, here's what I have done: > > http://tarek.pastebin.mozilla.org/1372473 > > - the url is passed along the ConnectionFairy checkout method, so I > can decide if I have to switch the database > - I keep a few globals to decide lazily if a database should be initialized > - I keep one engine and one pool *per server* > > it seems to work, here's an example of usage with the query() function: > > http://tarek.pastebin.mozilla.org/1372476 > > So, now I am pretty sure most of this code is crappy, and there's a > better way to do this. I still need to make sure all of this is > thread-safe. > > Thoughts ? Feedback ?
I should look at this more closely, took a brief glance. One thought I had was why not do the "switch the schema" thing within Engine.connect(), at least there you know which engine you're dealing with. Though I don't really understand how this is organized anyway, the query() function for example seems a little weird, wouldn't you want this to be transparent at the Engine level ? There should be a simple way to make two engines talk to one pool and switch the "schema" based on each engine. Maybe some context to be provided to the checkout event- possibly a small API change. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.