#1052: jsonify for SQLAlchemy mapped objects
-------------------------+--------------------------------------------------
Reporter: Arnar | Owner: anonymous
Type: enhancement | Status: new
Priority: high | Milestone: 1.0b2
Component: SQLAlchemy | Version: 0.9a6
Severity: normal | Resolution:
Keywords: |
-------------------------+--------------------------------------------------
Comment (by alberto):
The previous snippet within a patch (preferably with accompanying tests)
would be great.
I might have some time to do it, however I have some questions:
1. Where should I stuff this in? I vote for a new turbogears/json.py file
which just gets imported by {{{__init__.py}}} (though I haven't tested
it's viability regarding circular imports). This could be a nice place to
stuff these general-purpose jsonify recipes that happen to come long and
cover the use-cases of a wide enough user base.
1. What's the intended behaviour for jsonify_salist? I guess it means to
jsonify all "SA objects" in an object's relations, if this is the case
then it should read:
{{{
#!py
@jsonify.when("isinstance(obj,
sqlalchemy.attributes.InstrumentedList)")
def jsonify_salist(obj):
return map(jsonify, obj)
}}}
However, that would go berserk (read raise a "RuntimeError: maximum
recursion depth exceeded") if we run across circular dependencies.
Just speculating on 2, a passing test will surely prove me wrong ;)
Alberto
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/1052>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" 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-tickets
-~----------~----~----~----~------~----~------~--~---