I should point out that my suggestion wasn't intended to be syntactic sugar. Using the 'with' statement would (hopefully) allow embedding other logic and objects in HTML helpers thereby allowing full templating in Python. i.e.:
with DIV(_class='test') as d: with TABLE(_id='mytable): rows=db(db.mytable.myfield!=None).select() for r in rows: with TR(_class='datarow'): with TD(r.title): pass Then you could build re-usable chunks of template code for views, widgets, etc. You could also build base classes for your views and inherit from them, overriding any part of the layout. I'll kick it around a bit and see if anything interesting emerges. On Jul 13, 7:01 pm, Yarko Tymciurak <yark...@gmail.com> wrote: > On Mon, Jul 13, 2009 at 6:42 PM, Joe Barnhart <joe.barnh...@gmail.com>wrote: > > > > > I see no benefit to using PEP343 just to provide syntactic sugar for > > this purpose. There is no REASON to use the "with" statement because > > we're not doing anything with exception handling here. It's only > > being used to create an input format that looks prettier to some eyes. > > > Am I missing something?? > > I haven't looked at this all that much, but I don't think exceptions are the > motivator as much as setup / cleanup needs. One of the examples is critical > sections / "with lock:..." > > One place this would be useful in gluon (to preserve context) would be a > useful way to improve csv file IO in gluon. > > > > > On Jul 13, 2:40 pm, Yarko Tymciurak <yark...@gmail.com> wrote: > > > There are 2 interesting aspects from Luis's blogger post: > > > > - to use with, classes need to consider contexts; > > > - the (to me, at least) interesting example of ASP.NET's xmlwriter class > > > (generating SVG dynamically) is... .NET specific; I'm off busy looking > > for > > > a python portable idiom to use in place of his last example... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---