On Sep 27, 2004, at 1:57 PM, Marc-Antoine Parent wrote:
I wrote some for the hell of it. Page patterns and children factories are dead easy; working my way through the forms logic right now. My only comment so far: I wish adding events did not require writing an interface. (Or does it? Don't answer if you're busy, I'll figure it out ;)
I expected something like class myPage(rend.Page): def action_someAction(self, ctx, *kwargs): ....
I'm ccing this to the list to solicit more general feedback.
I agree it should be easier and it's something I have been thinking about for a little while now. The main reason formless requires interfaces is because of the type annotation, coercion and error handling features of formless. If you are just submitting strings and don't care if they are valid or not it would be easy enough to do what you want to do:
class ActionPage(rend.Page): def renderHTTP(self, ctx): action = ctx.arg('action') if action: args = IRequest(ctx).args.copy() del args['action'] return getattr(self, 'action_%s' % action)(ctx, **args) return rend.Page.renderHTTP(self, ctx)
I might go ahead and add this to rend so people can use it if they want. The thing I like about this approach is that it is simple enough to get started quickly, since formless is a lot to swallow when you are learning the framework.
I still think the formless interface approach is valid and useful however, because of all the things you get from it:
* Form rendering * Error checking * Error form rendering * Type coercion * Method calling and property setting
Really, formless is designed as the ultimate REST architecture, where form POSTs only mutate server side objects and are immediately redirected to a GET for that same object. But it is overkill for simpler tasks. Maybe there should be some sort of middle ground.