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

Johan Carlsson [EasyPublisher] johanc@easypublisher.com
Mon, 14 Apr 2003 20:58:08 +0000


At 21:40 2003-04-14 +0200, Clemens Robbenhaar said:

>Hi Johan,
>a possibly very stupid question:

Hi Clemens,
I don't believe there is such a thing ;-)


>  > So:
>  > <form method="dispatcher_url">
>  > <input type="submit" name="do_this:dispatcher" value=" Do This ">
>  > </form>
>  >
>  > would add REQUEST['dispatcher']='do_this'
>
>and
>
><form action="dispatcher_url">
><input type="submit" name="this_one" value=" Do This ">
></form>
>
>currently adds  REQUEST['this_one']=' Do This '
>
>thus instead of:
>  >
>  > 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()
>  >
>
>one could say:
>
>   if REQUEST.get('this_one',None):
>       return self.do_this()
>   elif REQUEST.get('that_one',None):
>       return self.do_that()
>   else:
>       return self.just_show_it()
>
>Maybe I have overlooked something, but it looks like the functionality
>can be obtained with the current implementation without adding
>one more magic ':', doesn't it?

Fair point.

You wouldn't get the possibility to extract the name
of the operation to be performed, try if it exist and
execute it:

method_id = REQUEST.get('dispatcher')
method = getattr(self, method_id, None)

Which I probably going to need for my dispatcher class.

One other thing I noticed, but which I'm not sure is useful,
is the possibility of submitting several method_ids:

<input type="hidden" name="dispatcher" value="always_do">
<input type="submit" name="do_this:dispatcher" value=" Do This (and more) ">


This might very well be something that only I want (so I'll probably end up
"hot-patching" it anyway)

It would be nice to have some kind of plug-in capabilities in the ZPublisher
form field handling. It would make it possible to handle custom fields like
something like Formulator Field in an more integrated fashion.

Regards,
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