[Twisted-Python] how to get form values in woven?

Mike Mueller pyp at gmx.net
Thu Jan 8 23:16:12 EST 2004

I am just starting with woven. I couldn't find a simple example how to get 
the values from a submitted form. Reading the HOWTOs and searching the 
twisted mail archives as well as web didn't bring up what I was searching for.

An example:

from twisted.application import service, internet
from twisted.web.woven import page
from twisted.web import server, resource

class FirstPage(page.Page):
     template = """<html>
         <title>First Form</title>
           <h3>First Form</h3>
           <form action="processMyForm" method="post">
           <input type="text" id="Text1"/><br/>
           <input type="text" id="Text2"/><br/>
           <input type="submit" value="Send"/>
     def initialize(self, *args, **kwargs):
         self.numberOfProcessCalls = 0
     def wchild_processMyForm(self, request):
         self.numberOfProcessCalls += 1
         keysValues = []
         for k, v in request.__dict__.items():
             keysValues.append('%s:\t %s' %(k,v))
         model = {'keys-values': keysValues,
         return page.Page(model, template=
                              Number of calls:
                              <p model="number" view="Text" />
                              <h3>arg keys: values</h3>
                              <div model="keys-values" view="List">
                                 <p pattern="listItem" view="Text" />

p = FirstPage()
application = service.Application('SimpleForm')

There are several problems with this.

1.) wchild_processMyForm gets called twice every time the submit button is hit
2.) for the first call the method is post for, the second it is get
3.) arg is always {}, so nothing to process

Obviously, I am doing something wrong. Basically I just want to echo back 
the name/values pairs that where entered into the form. How do I do this 
with woven?



More information about the Twisted-Python mailing list