On Oct 11, 12:18 pm, "Florent Aide" <[EMAIL PROTECTED]> wrote: > Has you may have noticed in some previous posts, the decision to > remove implicit transaction is not yet final and it may not even > happen. > > > TG great is the existence of automatic transactions. I understand the > > requirement to turn off transactions at the controller level (or the > > Hummm, I said in my above post that we should write some plugin that > provides the transaction functionality, but outside the core. I don't > necessarily want to remove transactions altogether but remove the > transaction management from the core...
OK, sorry, I think I gave a knee-jerk response to the initial part of your post without reading the "bonus parts" in detail. Yes, I think a "transactional" decorator would work great. > Good question. The problem is that we may have controllers that don't > need a db connection, this has been asked in the past. One important > thing also is that we need to ensure a different scoped_session object > is used in each thread. Actually, if you do this at the module level (say in turbogears.database), you'll get threadlocal sessions automatically (this is the purpose of scoped_session -- see http://www.sqlalchemy.org/docs/04/documentation.html#unitofwork_contextual): session = scoped_session(sessionmaker()) session is now a class (ScopedSession) that will automagically create thread-local sessions for you to use with its classmethods (get, query, etc.). It's never actually required that you instantiate the class to use it. Since TG runs with a fixed thread pool, it would use session.close() at the end of each request to free up all the session resources. Controllers that don't need the session don't use it, and don't incur much overhead (except for the initial creation of a session for each thread + a trivial amount in ScopedSession.close() ) What do you think? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears Trunk" 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-trunk?hl=en -~----------~----~----~----~------~----~------~--~---
