Just Launched: You can now import projects and releases from Google Code onto SourceForge
We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps. Read More
From: Jim Kraai <jkraai@pa...> - 2002-02-22 20:11:21
Very cool, thanks!
From: Jason Hildebrand [mailto:jason@...]
Sent: Thursday, February 21, 2002 6:58 PM
To: Jim Kraai
Subject: Re: [Webware-discuss] Leaving PHP--WebWare CGI form variables
On Thu, 2002-02-21 at 20:45, Jim Kraai wrote:
> what are valid names for form variables
> in PHP I could use the following in the name attribute of an input elt:
> name result
> ----------- -------------
> "asdf" normal
> "asdf" creates array w/ name asdf and appends submitted value to
> that array
> "asdf[jkl]" creates array w/ name asdf and assigns asdf['jkl'] =
> submitted value
> Which of these (aside from the obvious first one) can I use in Python with
> the various cgi'ish things included in WebWare?
Webware will notice if there is more than one value for a specific key,
and will create a list for you. For example, I have a list of items
in a form, and each item has a checkbox next to it:
(I've simplified this code for the purpose of the example)
for i in mylist:
self.writeln( i['name'] )
self.writeln('<input type="checkbox" value="%s" name="checked">' %
So my form contains many "inputs" which have the name "checked".
So the user may select one or more items by checking the boxes.
In my action handler "delete", I need to check which items should be deleted
from the list.
checked = self.request().value('checked')
if type(checked) is not ListType:
checked = [ checked ]
mylist = [ item for item in mylist if item['id'] not in checked
> Do they all (mod_python, one shot, cgiwrapper, etc?) behave the same?
Yes, they should.
> Are there other constructs available to get vars into arrays?
I don't know... maybe others can answer this question.
Jason D. Hildebrand