[mod_python] Newbie Question

Sean Allen sean at monkeysnatchbanana.com
Fri Apr 11 09:07:57 EDT 2008


>>
>         if ! valid:
>            addcustomer(req, 'custome_name')

This can become an issue if you are concerned about what your url is.

For example if you do a mapping so that the url from save is:

/myapp/save

then that addcustomer return would appear as

/myapp/save

instead of your normal

/myapp/enter

type situation.

if the url is a concern in your application ( some it is, some it isnt )
then a redirect of some sort is what you want. you could either
parse query string in js on client ( arg ) or have your initial display
code work more like:

def addcustomer(req):

         req_data=util.FieldStorage(req)

         # now use req_data values to supply value="" elements to  
inputs below.
         # so addcustomer can be add/edit customer. multi-use instead  
of single.
         # afterall add is just a edit edge case
	html = """A bunch of html that displays among other things the
                  following form:
                    <form action=savecustomer method="get">
                      <input type="text" name="customer_name" value="">
                      <input type="submit">""""

	return html


More information about the Mod_python mailing list