On Apr 3, 10:15 am, [EMAIL PROTECTED] wrote:

> On Tue, 3 Apr 2007 at 12:53, George Sakkis wrote:
> > Ok, I see. So the way I now handle it is by checking if
> > cherrypy.request.params.get('tg_format') == 'json' and return the
> > appropriate dict. Kind of kludge but works for now.
>
> Fortunately, that is an unneeded kludge :)
>
> Take a look at the json.py file in your quickstart directory.  You can
> do something like:
>
>      @jsonify.when('isinstance(obj, YourClass)')
>      def jsonify_YourClass(obj):
>          return <your appropriate dict>

Nice, that's good to know. Actually if I go down this road, I'd like
to generalize it for any elixir Entity instances rather than
separately for each class. Of course there are issues such as which
attributes to serialize (all the 'public' data attributes seems a
reasonable default) and whether the serialization should be shallow or
deep (or more generally allow shallow/deep semantics per attribute
rather than global). Ugh, seems a lot of work to get it right and
cover all cases... nevermind :)

George


--~--~---------~--~----~------------~-------~--~----~
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