[mod_python] HTML POST handle

Jorey Bump list at joreybump.com
Sat Dec 4 14:28:33 EST 2004


Lee jundong wrote:
> Hi,
> 
>     I am newbie for Mod_Python.Today, i write code to handle HTML
> requst.But i failed.

Are you using Publisher, or another handler?

>     Follow code block is my python code:
> ----------------------------------------------
> from mod_python import util
> 
> def Login (req):
>     data = util.FieldStorage(req)
>     return "login:", data.keys()

If you're using the Publisher handler, you can simply do this:

def Login(req):
     return "login:", req.form.keys()



> ----------------------------------------------
>     HTML code is following:
> ----------------------------------------------
> <form method="POST" action="login.py/Login">
>               <table border="1" width="100%">
>                 <tr>
>                   <td width="100%" colspan="2">
>                     <p align="center">Login</p>
>                   </td>
>                 </tr>
>                 <tr>
>                   <td width="39%">User</td>
>                   <td width="61%"><input type="text" name="User" size="30"></td>
>                 </tr>
>                 <tr>
>                   <td width="39%">Password:</td>
>                   <td width="61%"><input type="password"
> name="Password" size="30"></td>
>                 </tr>
>                 <tr>
>                   <td width="100%" colspan="2">
>               <p align="center">
>               <input type="submit" value="Login" name="B1"></p>
>                   </td>
>                 </tr>
>               </table>
>             </form>
> ------------------------------------
> 
> The code execute result follow:
> ---------------------------------------------
> ('login:', [])
> 
> 
>    The python code can't get HTML request varible from result.How to do?
> 



More information about the Mod_python mailing list