JSON SQLObject Rollback error

1 view
Skip to first unread message

chiangf

unread,
Jan 19, 2007, 4:37:32 PM1/19/07
to TurboGears
I've been getting a strange error recently. I just upgraded to TG1.0
but I'm not sure if this has anything to do with this because I also
started using Ubuntu rather than Windows so the setup is all new.

On a page, I have the following code (simplified):
@turbogears.expose(format="json")
def subcategory(self, category_id):
try:
#return subcategories in the selected category via JSON
#subcategories = SubCategory.selectBy(categoryID=int(category_id))
subcategories = SubCategory.select(SubCategory.q.categoryID ==
category_id)
except SQLObjectNotFound:
raise cherrypy.NotFound

return dict(subcategories=subcategories)


In the code above, I have 2 lines which, in my mind, should be
identical, one with selectBy and the other with select. However, when
I access /subcategory/4?tg_format=json, the select line works perfectly
(i.e. prints out the results) while selectBy line gives the following
error:
File
"/usr/lib/python2.4/site-packages/SQLObject-0.7.2-py2.4.egg/sqlobject/dbconnection.py",
line 749, in assertActive
assert not self._obsolete, "This transaction has already gone through
ROLLBACK; begin another transaction"
AssertionError: This transaction has already gone through ROLLBACK;
begin another transaction

Does anyone know why this is? I'm almost certain that these two lines
ran the same way before I moved the server to Ubuntu and upgraded to
TG1.0 (from TG1.0b2).


Frank

Rick

unread,
Jan 23, 2007, 7:13:46 AM1/23/07
to TurboGears
This happened to me, too. Rolling back to TurboJson 0.9.9 fixed it for
me. I think that the problem was that the auto-transaction stuff was
returning a generator rather than a string, and so the jsonification
code wasn't actually called until the transaction was obsolete.

I don't know if TG 1.0.1 fixes this or not, but I know I had the
problem in TG 1.0

chiangf

unread,
Jan 23, 2007, 4:09:50 PM1/23/07
to TurboGears
I'm glad I'm not the only person with this error. Right now, my
temporary fix is just to use the select instead of using selectBy in my
JSON modules.

Reply all
Reply to author
Forward
0 new messages