[mod_python] **kw syntax

Gary Strangman strang at nmr.mgh.harvard.edu
Wed Jun 19 10:38:29 EST 2002

Hi all,

I'm relatively new to mod_python (and apache), and so I'll bet my problem
is probably a direct consequence of that. I'm using mod_python to
dynamically generate a list of HTML checkboxes from a database. The list
of checkboxes then get inserted into a <form> block on a web page. I want
the <form>'s POST method deliver the (keyword,value) pairs from the form
to a python-based handler. My problem is this: I can't get get the **kw
syntax to work with mod_python. That is, if my form looks like this ... 

<form action="makechanges" method="POST">
  <input type=checkbox name="name1" checked>One<br>
  <input type=checkbox name="name2" checked>Two<br>
  <input type=checkbox name="name3">Three<br>
  <input type=checkbox name="name4">Four<br>
  <input type="submit">

... and my python function is defined as follows ...

def makechanges(request, **kw):

... makechanges() receives kw={} regardless of the status of the
checkboxes. If instead my function is defined as ... 

def makechanges(request, name1=None, **kw):

... then makechanges() gets name1='on' (if the name1 box was checked), but
nothing in kw, again regardless of checkbox status. The same happens if I
define the function as ...

def makechanges(request, name1=None, *args, **kw):

Any ideas on how to handle dynamically generated forms in general (and/or
with dynamically generated checkbox name attributes in particular)? Oh,
all this is on python2.2, mod_python2.7.6, apache1.3.24, Win98. 


strang- at at@-nmr.mgh.harvard.edu

More information about the Mod_python mailing list