On Fri, Jul 24, 2009 at 6:37 AM, Diez B. Roggisch<[email protected]> wrote:
>
> 一首诗 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.
>
I agree with Diez on this.

pulling "everything in" is bad and putting too little is also bad.
__json__ was invented for these cases. Now could you please explain
why 40 tables = 40 __json__'s ? Sorry to say this but if you have back
and forth relationship to everything then there is something wrong
with your DB design instead of the json layer, allll those joins will
be painful and your network objects (size of the json data will be
huge).

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