Alberto Valverde wrote:

> I think this could be solved in two ways which would allow default
> rules to be bundled (after all, TG2 is all about providing sane
> defaults to make simple things simple, right?)

TG2 is about making simple things simple, but its not about doing it
at the expense of complex things. Bottom line: both of your options
make it much more difficult to write a simple custom jsonifier, and
don't really solve the problem in a simple way.

I want to have this at the top of my `json.py`:

@jsonify.when((Person,))
def jsonify_person(obj):
     ...

This is much simpler to write, and is way easier to explain to a new  
user
than something like this:

@jsonify.when("isinstance(obj, Person) and crazy_disambiguator(1001)")
def jsonify_person(obj):
     ...

Imagine having to write this 50-60 times (in my case)!

New users don't want to think about things like "generic function
disambiguation". I think your ideas are both fine ideas, but they
don't eliminate the need to be able to turn the defaults off.  I
think the simplest approach here is the best: put the defaults in
a separate module, and have them be imported by default in the
TG2 json.py template in your project. If you want to remove the
defaults, you can simply delete that line from your `json.py` and
you're set!

The simplest solution is the best, IMO :)

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

Reply via email to