#2214: Transaction already begun or not begun problem when raise 
InternalRedirect
------------------------+---------------------------------------------------
 Reporter:  victorlin   |       Owner:  faide                                   
              
     Type:  defect      |      Status:  new                                     
              
 Priority:  normal      |   Milestone:  1.1                                     
              
Component:  TurboGears  |     Version:  1.0.8                                   
              
 Severity:  normal      |    Keywords:  transaction internalredirect redirect 
database session
------------------------+---------------------------------------------------
 I encounter transaction already begun, or encounter not begun error when I
 call session.commit in exposed method. This problem occurs after I use
 InternalRedirect to perform internal redirection. I thought that's a bug
 of turbogears in the expose function. It guess it might start transaction
 twice, or no start. I try to fix the bug by add "del
 cherrypy.request.in_transaction" before internal redirect, it works. This
 is the method I wrote.

 {{{
     @tg.expose()
     def default(self, site_name, *args, **kwargs):
         cherrypy.request.site_name = site_name
         url = tg.url(['/site'] + list(args))
         if cherrypy.request.browser_url.endswith('/'):
             url += '/'
         log.debug('Internal redirect to %s with params %r', url, kwargs)
         # do this to prevent bug
         del cherrypy.request.in_transaction
         raise cherrypy.InternalRedirect(url, params=kwargs)
 }}}

 To reproduce "transaction already begun" error, raise
 cherrypy.InternalRedirect might work. The error do not occurs every time,
 it sometimes show up, sometimes not. However, call session.commit in
 exposed method do raise "no transaction begun" error every time.

-- 
Ticket URL: <http://trac.turbogears.org/ticket/2214>
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.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to