[mod_python] Newbie question: Fieldstorage is empty in the second handler

Daniel West dwmp at opti.cgi.net
Fri Jan 9 10:08:28 EST 2004


You're probably creating a FieldStorage in authenhandler() and then 
recreating the FieldStorage in your handler().  You're using a POST request 
so the when FieldStorage is created it reads the fields from the body of 
the request (GET requests put the variables in the header) via the 
req.read() method. Once you've read the body of the of a request, it cannot 
be read again.  So when your second FieldStorage is created, there is no 
body request data left to be read.

As it turns out, the req object you get in authenhandler() and handler() is 
the same object.  So when you create your first FieldStorage in 
authenhandler(), assign it to the req object and it will be available in 
your handler() function without having to recreate it again.

-Dan




At 02:12 PM 1/9/2004 +0100, you wrote:
>Hello,
>
>I have just started using mod_pyhon and have come to a problem I cannot 
>find an solution for:
>
>In my html file there is a hidden input named PATH:
>
><FORM method="post" action="/qwer/eval.py">
><INPUT type="hidden" name="PATH" value="/mhanel/physik/1b/2002-11-24"/>
>...
></FORM>
>
>When the form is submitted the PATH variable reaches the 
>authenhandler(req) which I can give out to a file:
>
>PATH=/schools/HTL-Imst/innenausbau/teachers/mhanel/physik/1b/2002-11-24
>
>but after that it does not reach the following handler(req) function. It 
>always raises an KeyError since the PATH variable does not exist in this 
>function anymore !
>Can anyone point me to the right direction ?
>
>
>
>cheers,
>
>Arno



More information about the Mod_python mailing list