On Jul 24, 2009, at 4:20 AM, 一首诗 wrote:

> we have 2 choices:
>
> 1. don't use relationship of SA to use the default encode mechanism of
> turbojson
> 2. write a customized "__json__"
>
> I think, the 1st choice is not acceptable in most cases, but the 2nd
> one is also annoying when we have more than 40 tables.


There's at least one other choice: Use the jsonify.when decorator. If  
you can define your criteria using hasattr instead of isinstance, then  
this should be less tedious than defining __json__ on every class.  
Sorry, I don't have an example of this I can post, as it was easier in  
my case to just use __json__  In fact, I'm not sure where the  
decorator is documented, but looking at the source it's pretty  
obvious, and it's just a thin wrapper of  
prioritized_methods.prioritized_when anyway.

Hope that helps.

Dave Broudy
Three Aspen Software
2922 Evergreen Pkwy, Suite 311
Evergreen, CO 80439
Email: [email protected] // Web: http://www.threeaspen.com
Office: 303.278.0908 // Fax: 303.500.3112
AIM/YIM: dbroudy
--~--~---------~--~----~------------~-------~--~----~
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