[mod_python] clarity on request.form

David Bear David.Bear at asu.edu
Tue May 23 23:55:32 EDT 2006


On Tue, May 23, 2006 at 08:31:04PM -0700, David Bear wrote:
> On Tue, May 23, 2006 at 11:17:45PM -0400, Graham Dumpleton wrote:
> > David Bear wrote ..
> > > >From the manual, I don't understand the following statement:
> > > '''
> > > Since a FieldStorage can only be instantiated once per request, one
> > > must not attempt to instantiate FieldStorage when using the Publisher
> > > handler and should use Request.form instead.
> > > '''
> > > 
> > > I've been using publisher as a dispatcher to select the next psp to
> > > serve. Does the above statement imply that I cannot do this?  Where is
> > > Request.form define? is Request not the same as req?
> > 
> > Add a argument called "req" to your published function and then
> > access "req.form".
> > 
> >   def index(req):
> >     form = req.form
> > 
> 
> okay. thats what I thought I could do. however, the paragraph from the
> manual tripped me up.
> 
> > Unfortunately PSP doesn't play too nice with publisher as far as
> > form creation and will create its own if you access "form" from
> > inside PSP page. If request is a GET request, although redundantly
> > created, the form will still work. If a POST request though, there
> > will be no fields as publisher already consumed it.
> 
> So, in order to pass req.form to a psp, I would need to copy it to
> some object? simple
> 
>    thisform = req.form
>    vars = thisform
>    return psp.PSP('somepsp.html', vars)
> 
> won't work? or will the assignment make a copy?
> 

I just tried 

    myform = copy.deepcopy(req.form)

and it failed.. 

where is req.form documented? I'm looking for its methods.

> > 
> > The work around for this is to use something like:
> > 
> >     page = psp.PSP(.....)
> >     page.run({"form": form})
> >     ...
> > 
> > There was discussion about having PSP understand convention of req.form
> > being populated by publisher and use it if it exists, but no consensus
> > was reached on whether it was a good idea or not.
> > 
> > Graham
> 
> -- 
> David Bear
> phone: 	480-965-8257
> fax: 	480-965-9189
> College of Public Programs/ASU
> Wilson Hall 232
> Tempe, AZ 85287-0803
>  "Beware the IP portfolio, everyone will be suspect of trespassing"

-- 
David Bear
phone: 	480-965-8257
fax: 	480-965-9189
College of Public Programs/ASU
Wilson Hall 232
Tempe, AZ 85287-0803
 "Beware the IP portfolio, everyone will be suspect of trespassing"


More information about the Mod_python mailing list