[Twisted-Python] Re: Resource.render() returning NOT_DONE_YET
Clark C. Evans
cce at clarkevans.com
Mon Apr 28 12:17:56 EDT 2003
On Mon, Apr 28, 2003 at 04:09:35PM +0000, Clark C. Evans wrote:
| I was just giving a quick Twisted tutorial to someone using
| twisted and as we were breaking page construction into more
| than one chunk... an unexpected stumbling block occurred --
| returning NOT_DONE_YET form the resource's render() function.
| I was thinking about two other options:
| 1. Perhaps NOT_DONE_YET could just be None, this
| way, it can be the default return value. As I'm
| browsing through my code this is the most common
| return... why not make it the default.
Err, this isn't exactly what I was thinking. What
I was proposing... if during the scope of the render()
function, req.write() is called, then a None value
would be an allowable return. And if None is returned,
req.finish() would be called automagically.
| 2. Alternatively, allow a Deferred to be a return
| value. Then the underlying caller can add
| result.finish() to the deferred chain. This
| has the advantage of not requiring finish() to
| really be managed. Either the return value is
| a string, a Deferred, (or for backwards compatibiliy
| NOT_DONE_YET). In either of the primary cases,
| result.finish() always gets called... thus making
| it easier on newbies.
| Ideally, both of the above options could be used...
More information about the Twisted-Python