Jorge Vargas wrote: > This discussion belongs in the trunk list So I have moved it there.
Thanks. I'll keep this in mind for the future :) > This is one of the big problems with the new set of renderers. I also > agree we need a better way for them. There is a ticket in trac about > it. Apparently this was solved http://trac.turbogears.org/ticket/2287 > if it wasn't enough fell free to give more input. (I did but never got > a reply from the original author of the patch) and this is a feature I > don't really use. The linked patch only solves one part of the problem, and ignores the rest. A proper solution would allow users to set *all* of the previous parameters in app_cfg. A full list of configuration parameters is available here: http://genshi.edgewall.org/wiki/Documentation/0.5.x/plugin.html All of these preferences need to be supported in order to have 1:1 feature parity with TurboGears 1.x, and even the 2.0 alpha series which I am coming from. >> 2. My application made heavy use of the "json.py" module, and defined >> jsonification functions using PEAK-Rules. I am super happy to get >> rid of PEAK-Rules as a dependency, but the existing replacement >> is completely inadequate. I think that there is real value in being >> able to define global JSON-ification rules in a separate module. >> > Inadequate is not a correct term. The replacement is a 95% replacement > and the only thing missing is this @when back when I was implementing > this I asked for feedback for example: > http://groups.google.com/group/turbogears-trunk/browse_thread/thread/7b21549b3fea370e/ > > and at least 2 other threads since no one replied (except mramm, who > said he was ok with getting rid of it) we wrote this off as a > not-so-common feature of TG1 which could be stripped. Well, you may not *like* the term, but "inadequate" definitely describes the situation for me. I have a very large library of JSON-ification rules that cannot be easily migrated without some form of generic dispatch. And, no, I didn't see that original thread and respond to it because I was quite busy at this time. Working for a startup has sucked up a lot of my attention, and I didn't even notice this particular change until now. If I had noticed earlier, I definitely would have brought it up :) Of course, that is entirely my fault for not paying enough attention. I can completely understand why the change was made, given the feedback at the time. > well a better solution (yet still monkeypatch) will be to monkeypatch > the type itself. that is something along the lines of. > > builtin.__json__ = my_custom_json() > > That said I'm willing to work with you on a solution for this where we > can extend tg.json.py Unfortunately, this solution doesn't work, since you cannot monkeypatch builtin types like datetime/time/date. This is one of the reasons the current solution is inadequate, because there is no cross-cutting way to easily define how builtin types are JSONified. >> 1. Make it possible to set Genshi's options using either my >> application's configuration file, or easily in app_cfg. This isn't >> that difficult to implement, and if this is the type of thing that >> would be accepted, I'd be happy to create a patch. >> > Definitely I think it should be in app.cfg. Excellent. Would you like to work on the patch, or shall I? > I'm -0 on this one. do we really need generic dispatch? can't we just > provide a hook to extend tg/json.py in theory all you will need is to > extend the buildin json serializer add rules for your custom types and > tell TG to use it. Its so much easier to use generic dispatch through simplegeneric. All that would need to be done to add support for generic JSON rules again would be to update the GenericJSON serializer in TG to check for generic JSON-ify rules at the top of its `default` method: from simplegeneric import generic @generic def jsonify(obj): '''existing "default" method rules go here''' class GenericJSON(JSONEncoder): def default(self, obj): return jsonify(obj) Maybe a tweak or two needs to be made, but that is largely all that needs to be done to go from "95%" to "100%". -- 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 -~----------~----~----~----~------~----~------~--~---
