Hi all,

How is custom jsonifying handled in TG2?

>From the docs I can understand that TurboJSON is deprecated. For my
application I prefer to use something like the jsonify.when decorator
and not to add the __json__ method to my objects (some of the objects
are external). Is it done like this:

root.py
----------
from myproject import json
from myproject.model import MyClass
...
@expose('json')
def index(self):
    myobj = MyClass()
    return {'result': myobj}

json.py
-----------
from turbojson.jsonify import jsonify
from myproject.model import MyClass
...
@jsonify.when('isinstance(obj, MyClass)')
def jsonify_myclass(obj):
    result = custom_jsonify_method(obj)
    return result

Or is the best practice in TG2 something different?

Best regards,
Jesper

-- 
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?hl=en.

Reply via email to