[Zope-dev] "Dispatch" argument solving submit button problem

Johan Carlsson [EasyPublisher] johanc@easypublisher.com
Mon, 14 Apr 2003 15:29:07 +0000


Hi,
I'm about to implement a view dispatcher and realized a problem that
I keep bumping into.

Using *:method (or *:action) in HTML form to direct the submission
to a special method works fine in most cases but leaves the URL in
the browser window short of the method used.
This makes handling of forms a little bit inconsistent, so I usually try to 
avoid it.

But I would like to add a similar approach *:dispatcher where instead of
redirecting the call to a methods the value (*) would be converted to a
key:value par in the REQUEST object. The value of a submit button can't
be used because it's the text of the button, and even though it's used in allot
of the ZMI it's easy to break code when the result method depends on a
specific value of the submit button.

So:
<form method="dispatcher_url">
<input type="submit" name="do_this:dispatcher" value=" Do This ">
</form>

would add REQUEST['dispatcher']='do_this'

This would then be easy for the dispatcher method at 'dispatcher_url'
to handle in a if-else structure (etc):

if REQUEST['dispatcher']=='do_this':
     return self.do_this()
elif REQUEST['dispatcher']=='do_that':
     return self.do_that()
else:
     return self.just_show_it()

It would be quite a small change in the HTTPRequest.

Any thoughts?
Johan Carlsson



-- 
Easy Publisher Developers Team
Johan Carlsson
johanc@easypublisher.com

Mail:
Birkagatan 9
SE-113 36  Stockholm
Sweden

Phone +46-(0)8-31 24 94
Fax +46-(0)8-673 04 44
Mobil +46-(0)70-558 25 24
http://www.easypublisher.com