[mod_python] processing checkbox field from form

Gregory (Grisha) Trubetskoy grisha at modpython.org
Mon Apr 2 12:31:37 EST 2001


I think the publisher modules already does what you're trying to do a
little bit cleaner

Grisha

On Mon, 2 Apr 2001, Alexis Iglauer wrote:

> A more elegant way could be to pass the parameters as a single
> dictionary, not as individual parameters - and then use .has_key() to
> check for the available params.
>
> I generally use the following code to split a URL into params (req is
> the apache request):
> -----------------
> URL = urlparse.urlparse (req.unparsed_uri)
> params = {}
> try:
>     for x in split(URL[4], '&'):
>         params[split(x,'=')[0]] = split(x,'=')[1]
> except IndexError:
>     pass
> ---------------------
>
> I then pass 'params' to my functions.  I can check for a checkbox
> called XXX by saying:
>
> if params.has_key('XXX'):
>
> This method will not happily handle multiple parameter values, but
> could easily be modified to do so.
>
> HTH
> Alexis
>
> --- Johannes Govaerts <johannes.govaerts at siemens.atea.be> wrote:
> > You can use default values to deal with the changing number of
> > parameters
> > in your function:
> > e.g. something like function(parameter1, parameter2, checkbox='not
> > checked')
> >
> > Johannes.
> >
> >
> > On Mon, 02 Apr 2001 13:43:51 Jiri Lisicky wrote:
> > > I am beginner on python and mod_python.
> > >
> > > When I have form without checkbox field, everythig is OK. I use
> > > publisher and get fields as parameters of function.
> > >
> > > But when I add checkbox field I get to trouble. Number of
> > parameters
> > > is changing. In html documentation I found: "Unselected checkboxes
> > and
> > > radio buttons do not return name/value pairs when the form is
> > > submitted."
> > >
> > > I don't know how write function for processing this parameters from
> > > that form.
> > >
> > > Is somewhere any example for my problem?
> > >
> > > thanks
> > >
> > > warning: my english is poor
> > > --
> > >         JiЬМ LisickЩ                      хD KM╝P Olomouc
> > > e-mail: lisicky at datis.cdrail.cz           VМdeРskА 15
> > >  phone: +420-068-472-2272                 Olomouc, Czech Republic
> > >               >>> Хe╧tina ISO-8859-2 Compatible <<<
> > > _______________________________________________
> > > Mod_python mailing list
> > > Mod_python at modpython.org
> > > http://www.modpython.org/mailman/listinfo/mod_python
> > >
> > >
> > _______________________________________________
> > Mod_python mailing list
> > Mod_python at modpython.org
> > http://www.modpython.org/mailman/listinfo/mod_python
>
>
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/?.refer=text
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python
>




More information about the Mod_python mailing list