On 4/1/06, Patrick Coleman <
[EMAIL PROTECTED]> wrote:
Hi,
I have the following code in several places in my application:
model.hub.begin()
try:
<Database operations>
except:
model.hub.rollback()
raise
else:
model.hub.commit()
I have seen this code recommended in a few topics on this group as
being the Right Thing To Do :). It works brilliantly, except in the
situation where the database operations raise an exception. I would
expect then that any changes would be rolled back and the exception
would be re-raised. Instead I'm getting the following backtrace:
Traceback (most recent call last):
File
"/usr/lib/python2.4/site-packages/CherryPy-2.1.0_rc2-py2.4.egg/cherrypy/_cphttptools.py",
line 271, in run
main()
File
"/usr/lib/python2.4/site-packages/CherryPy- 2.1.0_rc2-py2.4.egg/cherrypy/_cphttptools.py",
line 502, in main
body = page_handler(*args, **cherrypy.request.paramMap)
File
"/usr/lib/python2.4/site-packages/TurboGears-0.8a3-py2.4.egg/turbogears/controllers.py",
line 121, in newfunc
output = func(self, *args, **kw)
File "/var/www/htdocs-members/members/domain/__init__.py", line 29,
in index
return self.delete(*args[1:], **kw)
File
"/usr/lib/python2.4/site-packages/TurboGears- 0.8a3-py2.4.egg/turbogears/controllers.py",
line 121, in newfunc
output = func(self, *args, **kw)
File "/var/www/htdocs-members/members/domain/__init__.py", line 165,
in delete
model.hub.rollback ()
File
"/usr/lib/python2.4/site-packages/TurboGears-0.8a3-py2.4.egg/turbogears/database.py",
line 65, in rollback
self.threadingLocal.connection.rollback()
File
"/usr/lib/python2.4/site-packages/SQLObject- 0.7.0-py2.4.egg/sqlobject/dbconnection.py",
line 778, in rollback
inst.expire()
TypeError: 'long' object is not callable
...which to me suggests that for whatever reason the rollback itself is
throwing an exception. Nothing is actually rolled back when this
happens. When I comment out the rollback line then the underlying
exception is re-raised as expected.
I haven't been able to find anyone with a similar problem either here
or elsewhere - am I doing something wrong? Turbogears version is 0.8.
Cheers,
Patrick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" 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
-~----------~----~----~----~------~----~------~--~---

