[Twisted-web] Possible bug in freeform List cont.
twisted-web@twistedmatrix.com
twisted-web@twistedmatrix.com
Thu, 29 Jan 2004 11:52:43 +0200
Hi,
in addition to Gavrie's mail from the 01/01/2004.
I have done a little debugging myself on this issue.
It seems that when render itself implements a formless interface, rather than apply a seperate class as 'original'
which implements a formless interface(see examples).
1. Both forms are construction appears to be ok
2. when clicking on the submit button of a list item
formpost4-bad.tac program raise an exception.
3. All hell breaks through when trying to configurate
a configurable object in postForm (freeform.py)
4. formpost4-good.tac comes back ok on second call
with the configurable list of [Address(), Address()..
TypedInterfaceConfigurable
where formpost4-bad.tac returns a
TypedInterfaceConfigurable - FormPost() insted of
the above.
5. Values returned bad from method locateConfigurable()
in freeform.py
Help would be very much appreciated on figuring
the matter.
I'm using Twisted 1.1.0 and the latest Quotient CVS
Gavrie's mail and the attached examples:
I took one of Donovan's examples (at
http://www.livejournal.com/users/fzzzy/) and modified it to work this
way, but to no avail.
Attached are two scripts, based in the freeformpost4.tac example. The
formpost4-good.tac uses a separate class that implements the formless
interface, and works perfectly.
The formpost4-bad.tac script uses a Renderer subclass which also
implements the formless interface (I need to do it this way because my
pages include forms and also other renderers on the same page). However,
this script renders the form fine, but blows up when submitting the form
(traceback attached).
Any form that does not use the formless.List type does work correctly
this way (i.e. using a Renderer subclass which implements the formless
interface).
Help would be very much appreciated.
I'm using Twisted 1.1.0 with the latest nevow code from the Quotient CVS.
Thanks,
-- Gavrie.
--------------090003070107020805050604
Content-Type: text/plain;
name="formpost4-bad.tac"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="formpost4-bad.tac"
from twisted.application import service, internet
from nevow import appserver
from nevow import renderer
from nevow import tags
from nevow import formless
from nevow import freeform
import nevow
class IAddress(formless.TypedInterface):
street = formless.String()
class Address(object):
__implements__ = IAddress
street = "foo"
def __str__(self):
return "%s" % self.street
class IPerson(formless.TypedInterface):
addresses = formless.List()
class FormPage(renderer.Renderer):
__implements__ = IPerson, renderer.Renderer.__implements__
name = "a person's name"
addresses = [Address(), Address(), Address()]
document = tags.html[
tags.head[
tags.link(href="/freeform_css", rel="stylesheet")
],
tags.body[
freeform.configure
]
]
def child_freeform_css(self, request):
from twisted.python import util
from twisted.web import static
return static.File(util.sibpath(nevow.__file__, 'freeform-default.css'))
application = service.Application("form")
internet.TCPServer(
8081,
appserver.NevowSite(
FormPage()#Person())
)
).setServiceParent(application)
# vim: ft=python
--------------090003070107020805050604
Content-Type: text/plain;
name="formpost4-good.tac"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="formpost4-good.tac"
from twisted.application import service, internet
from nevow import appserver
from nevow import renderer
from nevow import tags
from nevow import formless
from nevow import freeform
import nevow
class IAddress(formless.TypedInterface):
street = formless.String()
class Address(object):
__implements__ = IAddress
street = "foo"
def __str__(self):
return "%s" % self.street
class IPerson(formless.TypedInterface):
addresses = formless.List()
class Person(object):
__implements__ = IPerson
name = "a person's name"
addresses = [Address(), Address(), Address()]
class FormPage(renderer.Renderer):
document = tags.html[
tags.head[
tags.link(href="/freeform_css", rel="stylesheet")
],
tags.body[
freeform.configure
]
]
def child_freeform_css(self, request):
from twisted.python import util
from twisted.web import static
return static.File(util.sibpath(nevow.__file__, 'freeform-default.css'))
application = service.Application("form")
internet.TCPServer(
8080,
appserver.NevowSite(
FormPage(Person())
)
).setServiceParent(application)
# vim: ft=python
--------------090003070107020805050604
Content-Type: text/plain;
name="traceback"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="traceback"
2004/01/01 12:07 IST [HTTPChannel,0,127.0.0.1] Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/twisted/protocols/http.py", line 950, in lineReceiv
ed
self.allContentReceived()
File "/usr/lib/python2.3/site-packages/twisted/protocols/http.py", line 991, in allContent
Received
req.requestReceived(command, path, version)
File "/usr/lib/python2.3/site-packages/twisted/protocols/http.py", line 549, in requestRec
eived
self.process()
File "/usr/lib/python2.3/site-packages/nevow/appserver.py", line 99, in process
return server.Request.process(self)
--- <exception caught here> ---
File "/usr/lib/python2.3/site-packages/twisted/web/server.py", line 158, in process
resrc = self.site.getResourceFor(self)
File "/usr/lib/python2.3/site-packages/nevow/appserver.py", line 125, in getResourceFor
res = gener.getResourceForRequest(request)
File "/usr/lib/python2.3/site-packages/nevow/appserver.py", line 50, in getResourceForReqest
return self.postForm(request, res, configurable, ctx, bindingName, request.args)
File "/usr/lib/python2.3/site-packages/nevow/appserver.py", line 53, in postForm
return configurable.postForm(ctx, bindingName, args)
File "/usr/lib/python2.3/site-packages/nevow/freeform.py", line 750, in postForm
binding = configurable.getBinding(ctx, seg)
File "/usr/lib/python2.3/site-packages/nevow/freeform.py", line 735, in getBinding
raise ImproperInputError, name
nevow.freeform.ImproperInputError: 0