[mod_python] Re: Quickie question for you

Graham Dumpleton grahamd at dscpl.com.au
Wed Mar 16 18:24:51 EST 2005


I have now pushed this discussion onto the mailing where
it should be. :-)

 Davin Boling wrote ..
> Thing is, I'm specifying the method manually. I should have mentioned that.
> 
> 
> <form action="http://demo.wordpainter.net/content/login" method="post">
>        <div>
>         Handle:
>         <input type="text" name="handle" maxlength="32"/>
> 
>         Password:
>         <input type="password" name="password" maxlength="32"/>
>         <input type="submit" name="login" value="Log in!"/>
>        </div>
> </form>
> 
> 
> When a submission is made from this form, I can't pull "handle", 
> "password", or even "login" from a util.FieldStorage instance. req.read
> appears to be returning a blank string.

Without the code for your specific handler, hard to tell. If by handler
you simply mean something that is running under mod_python.publisher
then mod_python.publisher will already have consumed all data for a
post and so req.read() wouldn't return anything nor would FieldStorage
be able to decode anything for a post if you ran it your self. In the case
of mod_python.publisher, the FieldStorage instance it created will be
accessible as req.form.

I suggest you show the code for this handler and also describe how
you are defining the PythonHandler directive.

> Graham Dumpleton wrote:
> 
> > 
> > On 17/03/2005, at 6:17 AM, Davin Boling wrote:
> > 
> >> I know I should take this to the list instead of bugging you directly,
> >> but after searching the last few months on the mod_python mailing list
> >> you seem to be the one who knows the most about what he's talking 
> >> about anyway. (read: I'm lazy but flattery will get me everywhere.)
> >> Seriously though, let me know if writing you direct is a problem - 
> >> I'll try not to make it a habit. ;D
> >>
> >> I'm experimenting with writing my own handler still for the sake of
> >> understanding mod_python's internals, but I can't figure out how to
> >> handle POST forms for the life of me. As an experiment, I had my 
> >> handler write the result of req.method to a debug page just to see 
> >> what was going on...and it seems to be returning "GET" every time!
> >>
> >> I suspect I'm going about this the wrong way, and that the actual POST
> >> data is sent in a seperate request perhaps? Even so, I'm still having
> >> trouble tracking down where the POST data is actually being 
> >> sent...even with a "if req.method == 'POST':" trap that logs an error,
> >> I'm still not finding it.
> >>
> >> If you could give me a nudge in the right direction I'd really 
> >> appreciate it. I've tried FAQs, searching through the last few months
> >> of the mailing list, Googling, looking at source code...I'm quite 
> >> obviously missing something here.
> > 
> > 
> > Whether a GET or POST is used for a request is dictated by the HTML form
> > being
> > used as the trigger for the request. Take the following form for example:
> > 
> > <FORM method="POST">
> >     <P>
> >     First name: <INPUT type="text" name="firstname"><BR>
> >     Last name: <INPUT type="text" name="lastname"><BR>
> >     email: <INPUT type="text" name="email"><BR>
> >     <INPUT type="radio" name="sex" value="Male"> Male<BR>
> >     <INPUT type="radio" name="sex" value="Female"> Female<BR>
> >     <INPUT type="submit" value="Send"> <INPUT type="reset">
> >     </P>
> >  </FORM>
> > 
> > See how "method" attribute of the "FORM" element is set to "POST". This
> > makes the
> > form be sent as a POST as opposed to a GET.
> > 
> > Thus, look up information of HTML forms and the difference between GET
> > and POST
> > when using them.
> > 
> > Graham
> > 


More information about the Mod_python mailing list