#870: sqlalchemy in database.py is annoying
--------------------------------+-------------------------------------------
 Reporter:  [EMAIL PROTECTED]  |       Owner:  anonymous
     Type:  defect              |      Status:  new      
 Priority:  normal              |   Milestone:  1.0b1    
Component:  TurboGears          |     Version:  0.9a6    
 Severity:  normal              |    Keywords:           
--------------------------------+-------------------------------------------
 I don't have a better title sorry.

 current sqlalchemy support does this in database.py

 {{{
 objectstore.clear()
 do_your_thing()
 objectstore.commit()
 }}}

 here's the issue - because of the clear and commit situated where they
 are, sqlalchemy objects can't persist througout the request - they're
 locked into whichever cherrypy API stage that you created them in

 as an example:
     you load session info in before_request_body - ok
     tg calls the clear/commit
     you want to write session info in before_finalize based on what
 happened in the exposed method - failure, because clear/commit happened

 suggested approach:
    a filter calls a clear() on thread init , and the clear code from
 database.py become a begin

 database.py
 {{{
              if sqlalchemy:
 -                # flush any cached objects
 -                sqlalchemy.objectstore.clear()
 +               sqlalchemy.objectstore.begin()
             retval = func(*args, **kw)
 }}}

 {{{
 class SQLalchemyFilter( object ):
     def on_start_resource(self):
         # flush any cached objects
         sqlalchemy.objectstore.clear()
 cherrypy.root._cp_filters.append( SQLalchemyFilter() )
 }}}

-- 
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/870>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Tickets" 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-tickets
-~----------~----~----~----~------~----~------~--~---

Reply via email to