My classes are subclassed from app.page (i use web.autoapplication). But i got your point.
And what do you think about my suggestion of storing validation errors in session? If the site gets complex and the same form needs to appear on different places across the site--then having post requests result with redirect back to get request can be very useful. On Jan 25, 12:02 am, Branko Vukelić <[email protected]> wrote: > On Mon, Jan 24, 2011 at 9:51 PM, andrei <[email protected]> wrote: > > Do you mean two different urls are pointed to one controller class? > > Two controller classes. If you use my sweet class, it would be one > controller class, but with stock web.py, it's two classes. Either way, > it makes very little difference (see below). > > > Because having two controller classes for every form post will result > > duplicate code (for gathering data and returning template). > > Not if you use a superclass to abstract away those duplications: > > class DoubleForm(object): > def validate(self): > # do validation and other common stuff > > def respond(self): > # return template > > class FirstForm(DoubleForm): > def POST(self): > self.validate() > # etc etc 1 > self.respond() > > class SecondForm(DoubleForm): > def POST(self): > self.validate() > # etc etc 2 > self.respond() > > I actually had a whole framework-like superclass than handled grunt > work on top of web.py. And instead of writing simple controller > classes, I wrote subclasses of that superclass. You can find the code > (no longer maintained) in my github fork.[1] Using classes gives you > tremendous power, so this type of duplication isn't really a problem. > > [1]https://github.com/foxbunny/webpy/blob/foxbunny/web/contrib/sweet.py > > -- > Branko Vukelic > > [email protected]http://www.brankovukelic.com/ -- You received this message because you are subscribed to the Google Groups "web.py" 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/webpy?hl=en.
