一首诗 schrieb:
> That sounds reasonable.
> 
> But, for your facebook example,  there is another problem.  If we
> don't want to get these 4000 thousand friends,
> 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.
> 
> So, how about this :
> 
>     Find a way to mark fields of an object that should be skimmed when
> encode it to JSON.

But the __json__-method is exactly such a spceification. And both the 
__json__-method as well as any declarative approach you suggest (which 
would be *very* hard to implement for us, because its's 
SQLAlchemy/SQLObject that we'd need to change) are IMHO to limited anyway.

Because there might be occasions where I different json-representations 
for the same classes.

So instead, I suggest you familiarize yourself with the simplejson API. 
There you can declare custom serializers, and if you want, write one 
that knows how to fully traverse an SA-object and it's relations.

This could be very well a recipe in the docs - but I don't think it's 
justified to be included in the core, as the need for customization is 
very high so everybody will have to write json-encoders anyway.

Diez

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