[Twisted-Python] Re: twisted web, documentation

Christopher Armstrong radix at twistedmatrix.com
Tue Apr 29 15:44:58 EDT 2003

On 2003.04.29 14:51, François Pinard wrote:

> Your example (quoted in full below, for reference) has been both useful and
> instructive.  I have a question, though.  What is the purpose of `isLeaf'?
> It does not seem to be called ever, when I run your example.

> class ReportRequest(twisted.web.resource.Resource):
>     """ ReportRequest with forms and cookies """
>     def isLeaf(self):
>         return true

It looks like he meant to just say "isLeaf = True". It's expected to be an 
attribute, not a method. It worked accidentally because all function objects
are True.

What isLeaf *does* is to say "Stop looking for more children beyond me".
i.e., this resource will not have `getChild' called on it; it will be
immediately render()ed. You can handle the rest of the path segments by
accessing them through the request object passed to the render method.

 Twisted | Christopher Armstrong: International Man of Twistery
  Radix  |          Release Manager,  Twisted Project
---------+     http://twistedmatrix.com/users/radix.twistd/

More information about the Twisted-Python mailing list