[Twisted-web] Freeform/formless doesn't work with deferred properties?

Gavrie Philipson twisted-web@twistedmatrix.com
Wed, 24 Dec 2003 08:37:04 +0200


Donovan Preston wrote:
> 
> On Dec 22, 2003, at 10:38 AM, Gavrie Philipson wrote:
> 
>> Hi,
>>
>> I'm using freeform/formless to handle a form.
>> However, when the property returns a deferred value, it is not handled 
>> correctly by freeform.
>> Is this a bug?
>>
...
> Your suspicions about the freeform problem being related to the 
> attribute problem are correct; apparently nevow doesn't deal with 
> deferreds in attribute values properly. Are you sure you are using CVS 
> HEAD? I checked in some changes fairly recently which may affect the 
> situation.
> 
> Anyway, it's something that should certainly be fixed. In the meantime, 
> it's good that you have a workaround.

Donovan,

Christopher's workaround is fine, but doesn't solve the problem when 
using freeform.configure to render the form instead of my own form layout.

Anyway, I just did a 'cvs update' to get the latest HEAD, and guess 
what? Now my test script doesn't work at all!
When I run twistd -ony /tmp/formpost-defer.tac (the same script that I 
previously posted to this list), I get a traceback (see below).

Is this a bug? I did a clean install of the Quotient package and kept no 
old files around.

-- Gavrie.

2003/12/24 08:31 IST [-] Log opened.
2003/12/24 08:31 IST [-] twistd 1.1.0 (/usr/bin/python 2.3.2) starting up
2003/12/24 08:31 IST [-] reactor class: 
twisted.internet.default.SelectReactor
2003/12/24 08:31 IST [-] Loading /tmp/formpost-defer.tac...
2003/12/24 08:31 IST [-] 
/usr/lib/python2.3/site-packages/atop/store.py:36: 
exceptions.DeprecationWarning: This module is deprecated.
2003/12/24 08:31 IST [-] TODO: add IComponentized to Twisted so that we 
can do this without relying on getattr magic.
2003/12/24 08:31 IST [-] Loaded.
2003/12/24 08:31 IST [-] nevow.appserver.NevowSite starting on 8080
2003/12/24 08:31 IST [-] Starting factory <nevow.appserver.NevowSite 
instance at 0xbf0def6c>
2003/12/24 08:31 IST [HTTPChannel,0,127.0.0.1] Traceback (most recent 
call last):
           File 
"/usr/lib/python2.3/site-packages/twisted/internet/default.py", line 
501, in doSelect
             _logrun(selectable, _drdw, selectable, method, dict)
           File 
"/usr/lib/python2.3/site-packages/twisted/python/log.py", line 65, in 
callWithLogger
             callWithContext({"system": lp}, func, *args, **kw)
           File 
"/usr/lib/python2.3/site-packages/twisted/python/log.py", line 52, in 
callWithContext
             return context.call({ILogContext: newCtx}, func, *args, **kw)
           File 
"/usr/lib/python2.3/site-packages/twisted/python/context.py", line 32, 
in callWithContext
             return func(*args,**kw)
         --- <exception caught here> ---
           File 
"/usr/lib/python2.3/site-packages/twisted/internet/default.py", line 
510, in _doReadOrWrite
             why = getattr(selectable, method)()
           File 
"/usr/lib/python2.3/site-packages/twisted/internet/tcp.py", line 250, in 
doRead
             return self.protocol.dataReceived(data)
           File 
"/usr/lib/python2.3/site-packages/twisted/protocols/basic.py", line 223, 
in dataReceived
             why = self.lineReceived(line)
           File 
"/usr/lib/python2.3/site-packages/twisted/protocols/http.py", line 950, 
in lineReceived
             self.allContentReceived()
           File 
"/usr/lib/python2.3/site-packages/twisted/protocols/http.py", line 991, 
in allContentReceived
             req.requestReceived(command, path, version)
           File 
"/usr/lib/python2.3/site-packages/twisted/protocols/http.py", line 549, 
in requestReceived
             self.process()
           File "/usr/lib/python2.3/site-packages/nevow/appserver.py", 
line 115, in process
             return self.site.getResourceFor(self).addCallback(
           File "/usr/lib/python2.3/site-packages/nevow/appserver.py", 
line 202, in getResourceFor
             res = INewResource(self.resource)
           File 
"/usr/lib/python2.3/site-packages/twisted/python/components.py", line 
77, in __call__
             raise CannotAdapt("%s cannot be adapted to %s." %
         twisted.python.components.CannotAdapt: <FormPage object at 
0xbf0def4c> cannot be adapted to <class 'nevow.appserver.INewResource'>.