[Twisted-Python] Subclassing static.File

Donovan Preston dp at twistedmatrix.com
Mon Aug 4 18:28:06 MDT 2003


On Monday, August 4, 2003, at 5:10 PM, Rick Morrison wrote:
>
>     def render(self, request):
>         static.File.render(self, request)
>
> When I hit the site with a browser, the browser hangs. Interrupting the
> twisted session causes the page to immediately appear in the browser.
> ...Comment out the override of the render() function, and everything 
> works
> fine.
>
> What's going on?

You are not returning a value from render. The return value from render
be either a string, being the HTML output of the object, or 
server.NOT_DONE_YET,
in which case you should arrange to have request.write("<html />") and
request.finish() called at a later time.

In this case, you obviously want to return the value of the call to 
static.File.render:

def render(self, request):
	return static.File.render(self, request)

Wouldn't it be nice if the return value of a python function was the 
value of the last
expression in the function? ;-)

dp





More information about the Twisted-Python mailing list