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 #1310 (closed defect: fixed)

Opened 12 years ago

Last modified 11 years ago

TurboJson jsonify_object rollback assertion

Reported by: callan Owned by: anonymous
Priority: normal Milestone: 1.5
Component: TurboGears Version: 1.0.4b1
Severity: critical Keywords: turbojson jsonify sqlobject
Cc:

Description

TurboJson?-1.0 appears to be have some very odd problems where transactional boundaries are not being respected.

My exception:

2007-03-01 09:59:44,126 cherrypy.msg INFO HTTP: Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py", line 111, in _run
    cherrypy.response.finalize()
  File "/usr/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py", line 404, in finalize
    content = self.collapse_body()
  File "/usr/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py", line 375, in collapse_body
    newbody = ''.join([chunk for chunk in self.body])
  File "/usr/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py", line 343, in flattener
    for x in input:
  File "/usr/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/filters/sessionfilter.py", line 169, in saveData
    for line in body:
  File "/usr/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py", line 343, in flattener
    for x in input:
  File "/usr/lib64/python2.4/site-packages/simplejson-1.3-py2.4.egg/simplejson/encoder.py", line 223, in _iterencode
  File "/usr/lib64/python2.4/site-packages/simplejson-1.3-py2.4.egg/simplejson/encoder.py", line 196, in _iterencode_dict
  File "/usr/lib64/python2.4/site-packages/simplejson-1.3-py2.4.egg/simplejson/encoder.py", line 220, in _iterencode
  File "/usr/lib64/python2.4/site-packages/simplejson-1.3-py2.4.egg/simplejson/encoder.py", line 143, in _iterencode_list
  File "/usr/lib64/python2.4/site-packages/simplejson-1.3-py2.4.egg/simplejson/encoder.py", line 231, in _iterencode
  File "/usr/lib64/python2.4/site-packages/simplejson-1.3-py2.4.egg/simplejson/encoder.py", line 237, in _iterencode_default
  File "/usr/lib64/python2.4/site-packages/TurboJson-1.0-py2.4.egg/turbojson/jsonify.py", line 66, in default
    return jsonify(obj)
  File "<string>", line 5, in jsonify
  File "/usr/lib64/python2.4/site-packages/TurboJson-1.0-py2.4.egg/turbojson/jsonify.py", line 49, in jsonify_sqlobject
    result[name] = getattr(obj, name)
  File "<string>", line 1, in <lambda>
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.3-py2.4.egg/sqlobject/main.py", line 990, in _SO_loadValue
    selectResults = self._connection._SO_selectOne(self, dbNames)
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.3-py2.4.egg/sqlobject/dbconnection.py", line 823, in __getattr__
    self.assertActive()
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.3-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

There are further people having problems with this:

Rolling back to TurboJson?-0.9.9 seems to alleviate any issues.

Attachments

t1310.patch Download (493 bytes) - added by droggisch 12 years ago.

Change History

comment:1 Changed 12 years ago by callan

  • Owner set to anonymous
  • Priority changed from highest to normal
  • Component changed from unassigned to TurboGears
  • Severity changed from normal to critical

comment:2 Changed 12 years ago by alberto

  • Milestone changed from 1.0.2 to 1.0.3

comment:3 Changed 12 years ago by faide

  • Milestone changed from 1.0.3 to 1.1

comment:4 Changed 12 years ago by kierano

See also http://trac.turbogears.org/ticket/1253.

I've been having this bug, too. Same solution: Downgrading to TurboJson?-0.9.9 solved everything.

Again, the problem seems to be with jsonification of the results of certain SQLObject operations, specifically .select and .selectBy . The .get operation doesn't cause these errors.

Note: This is a pretty major bug, forcing quite a few people to run partially outdated code in their TurboGears systems. I'm a bit concerned that no-one is taking this up.

comment:6 Changed 12 years ago by vinces1979

I had this error running a mysql connection, I switched to the "sqlobject.dburi="notrans_mysql:" and that fixed the error.

comment:7 Changed 12 years ago by droggisch

I found the problem - it's an lazy-evaluation that was introduced to JsonSupport?, thus postponing the actual evaluation beyond transaction limits.

Find the attached patch for TJ 1.1.

Changed 12 years ago by droggisch

comment:8 Changed 12 years ago by bsouthey

  • Version changed from 1.0 to 1.0.4b1

I had a similar error even after updating to 1.04 beta until I just @exposed my function that implements the action button from the form.

I was following the outline provided by the 'Simple Widget Form Tutorial' at  http://docs.turbogears.org/1.0/SimpleWidgetForm in code. This tutorial uses @expose() above the action function 'save'. However this gave the same error until I used the equivalent of @expose(templates.save).

comment:9 Changed 11 years ago by Chris Arndt

  • Keywords turbojson jsonify sqlobject added
  • Summary changed from JSON jsonify_object rollback assertion to TurboJson jsonify_object rollback assertion

comment:10 Changed 11 years ago by chrisz

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

The patch has been applied in r3522 (TurboJson? 1.1.1). If you're still seeing similar errors after updating TurboJson? to the latest version, please reopen. Please attach your code with controller and model so we can reproduce this (the Widget Form Tutorial mentioned above does not use SQLObject at all).

Note: See TracTickets for help on using tickets.