Alberto Valverde wrote:
> Option 2 involves subclassing TJs encoder, in what way isn't that
> simple? (and it might solve another bug for free as Chris Z has
> pointed out)
Maybe I misunderstood, would rules still be able to be functions,
rather than methods? I was under the impression that this method
would involve changing the way that jsonification rules are
written. If that isn't the case, then my objections to this method
are completely withdrawn :)
> Option 1 involves *no* change in user code since TJ's
> implementations can have a lower priority than the default so any
> extension made by the user automatically overrides the built ins
> (I thought I had emphasized this point...).
Yeah, in my exhausted stupor, I must have missed that detail :) As
long as the user's rules *always* override the defaults, I am a
happy man! Objection withdrawn to this solution.
> The following command could save you some time ;)
>
> $ find . -name '*.py' -exec sed -e -i 's/\(@jsonify.*\))$/\1,
> 1)/g' {} ';'
Ah, sed! Incidentally, this is exactly what I would have done :)
> So if you only need to override how Person is jsonified you
> suddenly need to copy and paste (or re-implement for the fun of
> it) the rule to jsonify all other SA mapped objects from tg since
> you turned it turned it off en masse.
Well, this is what I was doing, because I actually don't want every
single field of my SQLAlchemy objects to be serialized. I want to be
able to explicitly control it, which is why I don't like there being
no way to turn off the defaults! Having complete control over the
JSONification of my objects is extremely important to me.
> Both solutions I proposed allow to *selectively* extend the
> encoder while preserving rules any extension might have added or
> might need to add.
Sure, but I still want to be able to turn them off, even if it
does break some "future" extension. The bottom line for me is that
I totally understand (and agree with) your arguments, but I still
think that there needs to be a mechanism for clearing out the
default rules to give the user complete control over them.
Thanks for your hard work, Alberto!
--
Jonathan LaCour
http://cleverdevil.org
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---