[Maypole-dev] [PATCH] add param() method to application object
Simon Flack
sf@flacks.net
Thu, 9 Sep 2004 23:32:22 +0100
This is a multi-part message in MIME format.
------=OPENWEBMAIL_ATT_0.685138844725774
Content-Type: text/plain;
charset=iso-8859-1
A controversial patch perhaps, but I thought I'd put something together and
let the community decide...
It follows fairly closely the behaviour of CGI.pm and A::R's param() method
(WRT fetching params only). From the CGI docs:
Pass the param() method a single argument to fetch the
value of the named parameter. If the parameter is
multivalued (e.g. from multiple selections in a scrolling
list), you can ask to receive an array. Otherwise the
method will return a single value.
If the parameter does not exist at all, then param() will
return undef in a scalar context, and the empty list in a
list context.
This behaviour should be familiar to perl web developers. With the current
(svn snapshot) implimentation of Maypole, authors need to check whether a
single value or multiple values were submitted. param() should simplify
things.
It should work for any Maypole front-end that stores parameters in the
'params' slot. Other front-ends can impliment their own param() if required.
If accepted, it should be documented somewhere. Maypole.pm's documentation
seems to be an overview, mostly duplicating information in the docs/ folder.
What's the plan for documentation and how can we help?
--simonflk
------=OPENWEBMAIL_ATT_0.685138844725774
Content-Type: application/octet-stream;
name="Maypole.pm-param.diff"
Content-Disposition: attachment; filename="Maypole.pm-param.diff"
Content-Transfer-Encoding: base64
SW5kZXg6IHRydW5rL2xpYi9NYXlwb2xlLnBtCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIHRydW5rL2xpYi9NYXlw
b2xlLnBtCShyZXZpc2lvbiAxNjkpCisrKyB0cnVuay9saWIvTWF5cG9sZS5wbQkod29ya2luZyBj
b3B5KQpAQCAtMTM1LDYgKzEzNSwyMyBAQAogICAgICRzZWxmLT57YXJnc30gPSBcQHBpOwogfQog
CitzdWIgcGFyYW0geworICAgIG15ICRyID0gc2hpZnQ7CisgICAgbXkgKCRrZXkpID0gQF87Cisg
ICAgaWYgKGRlZmluZWQgJGtleSkgeworICAgICAgICBteSAkdmFsID0gJHItPntwYXJhbXN9eyRr
ZXl9OworICAgICAgICBpZiAod2FudGFycmF5KCkpIHsKKyAgICAgICAgICAgIHJldHVybiAoKSB1
bmxlc3MgZGVmaW5lZCAkdmFsOworICAgICAgICAgICAgcmV0dXJuIHJlZiAkdmFsID8gQCR2YWwg
OiAkdmFsOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgcmV0dXJuIHVuZGVmIHVubGVz
cyBkZWZpbmVkICR2YWw7CisgICAgICAgICAgICByZXR1cm4gcmVmICR2YWwgPyAkdmFsLT5bMF0g
OiAkdmFsOworICAgICAgICB9CisgICAgfSBlbHNlIHsKKyAgICAgICAgcmV0dXJuIGtleXMgJXsk
ci0+e3BhcmFtc319OworICAgIH0KK30KKwogPWhlYWQxIE5BTUUKIAogTWF5cG9sZSAtIE1WQyB3
ZWIgYXBwbGljYXRpb24gZnJhbWV3b3JrCg==
------=OPENWEBMAIL_ATT_0.685138844725774--