On 23/04/2006, at 18:54, Jorge Godoy wrote:
> > Em Domingo 23 Abril 2006 13:28, Alberto Valverde escreveu: > >> Oh, and you might want to jsonify objects built from classes you >> cannot directly modify, like from an C extension. Ok, ok.. you can >> wrap that C extension's object and provide the __json__ method >> yourself... but I *personally* would favor writing a new rule to >> overload a generic function. A matter of taste I guess... > > Hmmm... I see two different approachs: one is OOP (__json__) > making the > objects know what to do; the other deals with generics. > > I also believe that we have to be very careful with what we use to > solve our > problems inside TG because that's what will be exposed to users. > We should > indeed opt for one alternative and doesn't make the other > impossible, i.e., > if the user thinks his problem can be best solved the other way, > then this > should be possible. I agree. At least in the jsonify case a "jsonify_explicit" function is added to operate on objects the have a __json__ method, therefore allowing both approaches: Add a rule to jsonify or provide a __json__ method in your objects. Unfortunately, I cannot think of a way to offer this flexibility in other "generic"alized parts of TG like errorhandling.py or the new "expose" (which I admit not understanding yet how it actually works or what advantages it offers :/). On the other hand, error_handler() doesn't need generic function awareness in it's simplest and most common cases, only when doing something fancy which in that case you can provide an optional "rule" parameter. > Some clashes might happen on unexpected areas and they will happen > but hey! > We're working to get it better everyday, right? :-) > > We have the knife and the cheese... We just have to take care when > we get to > our hands. ;-) Mmm, cheese... ;) Alberto --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

