[mod_python] Newbie needs help with forms

Jim binarybrain at phreaker.net
Sat Feb 14 08:52:24 EST 2004


I am new to modpython and I could use a hand with forms. I currently
have the publisher setup. The following snippit of code prints none of
the form vars that I (thought) I was passing. When I click submit test
gets loaded but the page is blank. I thought iterating through the keys
would work. What am I doing wrong here? 

TIA - Jim

from mod_python import apache, util
import HTMLgen
from HTMLgen import *

def test(req):
        html_page = HTMLgen.BasicDocument(title='Test')
        for i in util.FieldStorage(req).keys():
                html_page.append(i)
        return html_page
                                                
def handler(req):
        html_page = HTMLgen.BasicDocument(title='Register')
        f = Form('http://69.56.173.110/register.py/test')
        f.append("Please pick a username and password")
        f.append("Username")
        f.append(Input(type='textfield', name='username'))
        f.append("Password")
        f.append(Input(type='password', name='passwd'))
        f = space(f)
        role = ['Official', 'Coach', 'Parent', 'Player']
        for choice in role:
                r = Input(type='radio', name='role', rlabel=choice)
                f.append(r)
        f.submit = Input(type='submit', value='register')
        html_page.append(f)
        req.write(str(html_page))
        return req




More information about the Mod_python mailing list