[Twisted-Python] Form Processor hmmmm looks cool what does it do :)
jjanecek at telusplanet.net
Sun Aug 31 23:27:39 EDT 2003
Thanx to the dude who answered my last post :)
When i get some time i have to try and put into practive wxpython suggestions
I took the form processor example from the sandbox and made it do something.
What it is doing i am not quite sure :)
#simple proggie to test how to handle forms
#hacked together from myformstuf which is in the glyph directory in the sandbox
#not really sure if this is done right
from twisted.web.woven import page
#this module is required for the method def wmfactory_form(self, request):
from twisted.web.woven.form import FormProcessor
from twisted.python import formmethod as fm
class FormPage(page.Page) :
template = '''
<head><title>a form page</title>
<form action="post" model="form" />
formSignature = fm.MethodSignature(
fm.String("username","","User Name : ","Enter a user name"),
fm.Password("password","","Password : ","Enter a password")
def proc(self,**kw) :
print "proc : ",kw
def wmfactory_form(self, request):
print "factory form"
def wchild_post(self,request) :
print "child post ",request.args
#the test throttle code
def main() :
print "Main Loop"
from twisted.web.server import Site
from twisted.internet import reactor
self.proc is a required arguement.
It returns a dictionary with all the form variables in it when form is posted.
I am not really sure what am i supposed to do in this function. Like in
would this be where i could stick variables into a data base ?
The method FormProcessor(self.formSignature.method(self.proc)) appears from
to be able to take a second arguement where i can add my own view. If no
view is added
it uses the view that is provided by default. It would be kinda nice to
have my own view,
how would my own view be able to access the variables that are posted from
FormProcessor also appears to be able to take a 3rd arguement that is some
sort of error view,
what type of errors would happen, and how will they be triggered.
FormProcessor looks like the smart way to handle forms. Unfortunately I
seem to be missing a few pieces.
Well i will keep on plugging away at it :)
Hmmmm well anyways i am kinda lost i will think about being lost some more :))
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python