On Fri, Nov 13, 2009 at 9:44 AM, Jonathan LaCour <[email protected]> wrote: > Hello Jonathan,
This discussion belongs in the trunk list So I have moved it there. > I've been working this week on moving an application from an ancient > TurboGears 2.0 pre-release version, to TurboGears 2.1a2. First off, let > me say "great work" to all the people who have been contributing and > pushing TG forward. I salute you for all your hard work, and for doing > such a great job! > Thank you very much! > In the process of porting, there were a few little things that bothered > me and made updating my application a bit more difficult: > > 1. As much as I did not like Buffet, the new render function madness > has made it very difficult to set configuration options on our > template engines. In order to set Genshi to use lenient variable > lookup, and to output HTML rather than XHTML, I had to jump through > a lot of hoops. > 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. > 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. > In order to get this functionality back, I wrote this decorator: > > def when(typ): > def deco(func): > typ.__json__ = func > return func > return deco > > This works fine for my model objects, but doesn't allow me to > define custom JSON rules for builtin types, so I am having to > monkeypatch the TG jsonifier. All a bit hackish for my taste :) > 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 > Apart from these two issues, upgrading went very smoothly, and I am > noticing a bit of a speed bump throughout my application. Here are some > suggestions for addressing these two issues: > > 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. > 2. Rather than ignoring users that were using PEAK-Rules, add the > ability to register custom JSON-ification functions using something > much simpler like simplegeneric (available on PyPI, and pure > Python). The problem with PEAK-Rules was that it was crazy and > poorly maintained. The simplegeneric module has neither of these > problems and would restore a very nice capability back into TG. > 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. > Again, I'd be happy to contribute patches for either of these issues if > they are likely to be accepted. I'm curious to hear other people's > feedback on these ideas. > > All the best -- > > -- > Jonathan LaCour > CTO, ShootQ - http://shootq.com > Training - http://cleverdevil.org/train > Blog - 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 -~----------~----~----~----~------~----~------~--~---
