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

Opened 12 years ago

Last modified 11 years ago

TurboJson with SQLAlchemy support breaks use of explicit __json__

Reported by: kikidonk Owned by: anonymous
Priority: high Milestone: 1.5
Component: TurboGears Version: 1.0.4b2
Severity: major Keywords: turbojson jsonify sqlalchemy
Cc:

Description (last modified by Chris Arndt) (diff)

Starting with TurboJson?-1.1.1 (http://trac.turbogears.org/changeset/3418) a new code snippet was introduced to support sqlalchemy objects automatic jsonification.

Unfortunately as discussed in this mailing-list thread:  http://groups.google.com/group/turbogears/browse_thread/thread/71456c35669fb2bf

This renders the __json__ explicit method on sqlalchemy objects useless since it never gets picked up by the ruledispatch mechanism (worst case being an error about ambiguousmethod).

Suggested solution is to explicitely prevent automatic rules to kick in if __json__ is defined.

I'll attach a patch that adds the conditions (and not hasattr("__json__")) to automatic sqlalchemy/sqlobject jsonification rules.

Attachments

turbojson-jsonify-explicit-fix.patch Download (949 bytes) - added by kikidonk 12 years ago.
Add clauses to prevent ambiguous dispatch when an sql{alchemy,object} object has a json method.
turbojson-explicit-plus-test-cases.patch Download (4.3 KB) - added by kikidonk 12 years ago.
New patch with added test cases

Change History

Changed 12 years ago by kikidonk

Add clauses to prevent ambiguous dispatch when an sql{alchemy,object} object has a json method.

Changed 12 years ago by kikidonk

New patch with added test cases

comment:1 Changed 11 years ago by Chris Arndt

  • Summary changed from Turbojson with SQLAlchemy support breaks use of explicit __json__ to TurboJson with SQLAlchemy support breaks use of explicit __json__

comment:2 Changed 11 years ago by Chris Arndt

  • Description modified (diff)

The patch was applied in r3749. A new TurboJson (1.1.1 for TG 1.0.x, 1.2 for TG 1.1.x) version will be released soon.

comment:3 Changed 11 years ago by faide

  • Priority changed from normal to high

comment:4 Changed 11 years ago by faide

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

TJ as been released. Closing ticket.

Note: See TracTickets for help on using tickets.