I forget if I responded to this thread or not. :-)
Instead of looking through previous msgs, let me just say:
* I agree with Paul's concern
* I like Geoff's solution to my concern about searching through the fields
* We'll do this for 0.5. If someone wants to crank out the patch before
me, that would be fine. :-) But otherwise, I'll get to it.
* Any suggested prefixes other than _action_? What about 'perform_'? As
in 'perform_new'? Seems more readable to me and does what it says.
* I generally agree that functionality is more important than speed BUT
I avoid linear searches (and try to use caching) whenever possible while
writing fresh code in order to avoid creating performance problems.
At 12:29 PM 12/18/2000 +0100, Paul Boddie wrote:
>Geoff Talvola wrote:
> > Chuck Esterbrook wrote:
> > > On the one hand, using _action_Foo_ eliminates the need to map button
> > > titles to method names. On the other hand, this means that Page must
> > > always do this:
> > >
> > > for key in self.request().fields().keys():
> > > if key.startswith('_action_'):
> > > # handle action
> > >
> > > e.g., every request requires the construction of keys() and a linear
> > > search through them to determine if this request is using the "action
> > > feature". Mandatory linear searches scare me.
> > Couldn't you write it so it only had to do a linear search on the
> > results of actions(); i.e.
> > for action in self.actions():
> > if request.hasField('_action_%s' % action):
> > # handle action
> > That way you only pay a penalty proportional to the number of actions
> > defined on your page.
>This would surely be acceptable, since you aren't going to want to know about
>unhandled _action_*_ inputs anyway. As for the linear complexity aspect, I
>really think that this would be a problem in practice. Whilst people may have
>hundreds or even thousands of fields on a form, they are less likely to have
>hundreds or even thousands of submit buttons, and even if they did, I wouldn't
>necessarily envisage a massive performance hit.
> > > It's actually a bummer. I wish <input type=submit> had a "title="
> > > argument.
>Yes, this was a particularly badly thought out aspect of the HTML
> > > I guess we could avoid the linear search if we tapped into the
> > > translation of the query string to a dictionary. I don't know how easy
> > > that is; we're using the cgi module.
> > I say, make it as easy as possible for the developer; optimization can
> > come later if necessary. This makes actions easier to implement and
> > more understandable in my opinion, so I say let's do it.
>I agree. If we can't have a common set of action names, then in the
>of a "document" in a number of different languages, the developer is
>maintain a dictionary mapping action labels to action names in addition to the
>numerous editions of the document. This clearly introduces some
>the system, since maintenance of each edition involves the adjustment of more
>than one component in the system, namely the source code and the document
>I don't see why adding a new language to those already supported should
>necessarily require modification of the source code as well as the
>creation of a
>new edition of the document.
>Webware-discuss mailing list