[Twisted-Python] change submodel in a form
vicky lupien
vlupien at drummonddesigns.com
Fri Oct 31 07:52:25 MST 2003
I have a web base application. I want to change the data in the model
so that it will be update in the form when a post my form.
Here's my code:
from twisted.web.server import Site
from twisted.internet import reactor
from twisted.web.woven.page import Page
from twisted.web.woven.form import FormProcessor
from twisted.python import formmethod as fm
from twisted.web.woven import input, controller
from twisted.web import domhelpers
class FormPage(Page):
template = '''<html>
<head><title>a form page</title>
</head>
<body bgcolor="c0c0c0">
<!--<div model="args" view="Text"/>-->
<br/><br/>
<form action="post" method="post" enctype="multipart/form-data">
<table border="0">
<tr>
<td align="right" valign="top">Argument #1:</td>
<td valign="top"><input type="text" name="arg1" value="" size="60"
controller="int" />
<div class="formDescription">Hooray it is an argument.
</div></td>
</tr>
<tr>
<td align="right" valign="top">Integer Field.: *</td>
<td valign="top"><input type="text" name="arg2" value=""/>
<div class="formDescription">
</div></td>
</tr>
<tr>
<td align="right" valign="top">TEXT PLS:</td>
<td valign="top"><textarea wrap="virtual" rows="10" cols="60"
name="arg5">HERE IS THE DEFAULT OMG!@#!.</textarea>
<div class="formDescription">it is some text
</div></td>
</tr>
</table><input type="submit" />
</form>
</body>
</html>
'''
def __init__(self):
Page.__init__(self)
def checkName(self, request, name):
if name is None:
return None
return True
#def commitName(self, request, name=""):
# print self.model
def wvupdate_arg1(self, request, widget, model):
pass
def wmfactory_arg1(self, request):
return request.args.get('arg1')
def wcfactory_int(self, request, node, model):
self.submodel = self.model.getSubmodel(request, "arg1")
return input.InputHandler(
model,
name = "arg1",
check = self.checkName,
submodel = self.submodel)
#commit = self.commitName
def wchild_post(self, request):
return self
reactor.listenTCP(8585, Site(FormPage()))
reactor.run()
Here's the error I get:
exceptions.TypeError: process() keywords must be strings
I know that the error comes from controller but I don't know how to
correct it.
Maybe the error is because I'm not very familiar with form.
Thx in advance,
Vicky
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20031031/a8eb7bef/attachment.html>
More information about the Twisted-Python
mailing list