Alberto Valverde schrieb:
> 2) Add context to jsonify so it can be dispatched on. This can be achieved
> by implementing jsonify as a method of GenericEncoder, example:
> 
> class GenericEncoder(JSONEncoder):
>     @generic()
>     def jsonify(self, value):
>          ....

I was also thinking about this, because it could help removing another 
small wart in TurboJSON, namely the handling of config options.

The GenericEncoder is instantiated twice: When importing jsonify, a 
global instance is created, using default options, and when 
instantiating JsonSupport (the JSON templating engine), an additional 
instance is created, passing the proper config options on to 
JSONEncoder. Also, the specialized functions have no way of accessing 
these options. That's why turbojson.descent_bases has to be accessed in 
an obscure way, needing to import turbogears.config which leads to 
circular imports with the Pylons nose plugin. See also:
http://groups.google.de/group/turbogears-trunk/browse_thread/thread/c0f9e8b6c4ca4ca2
If we use methods instead of functions, it would be easier to access 
additional configuration options such as turbojson.descent_bases.

-- Christoph

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" 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-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to