[Twisted-Python] Re: Error Request did not return a string
Maarten ter Huurne
maarten at treewalker.org
Mon Aug 4 16:50:24 EDT 2008
On Monday 04 August 2008, DJ wrote:
> For some strange reason I this text is being added to the end of the html
> pages rendered by twisted.
> Request did not return a string
>
> Request:
>
> <GET /config/deleteSection HTTP/1.1>
>
>
> Resource:
>
> <configPages.deleteSection instance at 0x00EC4EE0>
>
>
> Value:
>
> None
>
> I am using the resource.Resource and render. My html is passed has a
> string using request.write.
> As far has I can tell, there should not be a problem. Does anyone know
> why and what I need to do to fix this.
Python functions implicitly return None if there is no return statement.
Twisted.web wants the render method to either return a string, or the
special object NOT_DONE_YET, which indicates that the reply will be written
with request.write(). The name was probably chosen for cases where the
content is written using deferreds, but it should be used even if you call
request.write() from the render method.
So try putting "return server.NOT_DONE_YET" at the end of your render
method.
Bye,
Maarten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20080804/e48a0bb0/attachment.pgp
More information about the Twisted-Python
mailing list