Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2214 (closed defect: invalid)

Opened 10 years ago

Last modified 10 years ago

Transaction already begun or not begun problem when raise InternalRedirect

Reported by: victorlin Owned by: faide
Priority: normal Milestone: 1.1
Component: TurboGears Version: 1.0.8
Severity: normal Keywords: needs feedback, 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.

    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.

Change History

comment:1 Changed 10 years ago by Chris Arndt

I'm having trouble understanding the problem, sine you are showing only part of the code that produces it. I know it is months since this has been reported, but if you are still having this problem, please post a full example exhibiting the problem.

Otherwise I'll close the ticket soon. No offense meant, but I think this is a rather esoteric problem anyway.

comment:2 Changed 10 years ago by Chris Arndt

  • Keywords needs feedback, transaction, internalredirect, redirect, database, added; transaction internalredirect redirect database removed

comment:3 Changed 10 years ago by Chris Arndt

  • Status changed from new to closed
  • Resolution set to invalid

Closing ticket as invalid because of missing feedback and the example in ticket description seems very fishy to me. If you still have this problem, please post to the mailing list with a more detailed description and a full test case to demonstrate the problem. Based on this discussion we can then decide whether this ticket should be reopened.

Note: See TracTickets for help on using tickets.