[Twisted-Python] Re: Error Request did not return a string
Hello All, 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. -- Dafina A. Abernathy (DJ)
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
Will request.finish have the same effect as return server.NOT_DONE_YET ? Or do the statements do different things ? On Mon, Aug 4, 2008 at 3:50 PM, Maarten ter Huurne <maarten@treewalker.org>wrote:
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
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- Dafina A. Abernathy (DJ)
On Tuesday 05 August 2008, DJ wrote:
Will request.finish have the same effect as return server.NOT_DONE_YET ? Or do the statements do different things ?
You have to use both: call request.finish() when you are done writing and return NOT_DONE_YET from the render method. Bye, Maarten
participants (2)
-
DJ
-
Maarten ter Huurne