[Twisted-web] Twisted-web Digest, Vol 151, Issue 2

Jason Harrison drjasonharrison at gmail.com
Thu Aug 9 11:32:24 MDT 2018


On Thu, 9 Aug 2018 at 09:31 am Jean-Paul Calderone <
exarkun at twistedmatrix.com> wrote:

> In the code you posted, DelayedResponse is the root resource.  The root
> resource *always* has to provide a child resource.  If someone requests
> /foo then the child is "foo".  If someone requests "/" then the child is
> "".
>
> isLeaf = True is a shortcut that stops traversal and uses the current
> resource as the requested resource.  Without this, DelayedResponse must
> have a child or it can only produce a 404.
>
> Maybe that explains it?  If there are examples in the documentation that
> have root resources with no children and without isLeaf = True then perhaps
> they are also broken and should be fixed.  If you see any, please point
> them out.
>
>
Thank you for the explanation! Let's see if I understand your explanation
and the variation in the examples.

https://twistedmatrix.com/documents/current/web/howto/web-in-60/custom-codes.html
does not have isLeaf = True because it has:

root = Resource()
root.putChild(b"buy", PaymentRequired())
factory = Site(root)


https://twistedmatrix.com/documents/current/web/howto/web-in-60/dynamic-content.html
does have isLeaf = True because it does not have a .putChild()

The explanation about isLeaf could be improved by:

Setting isLeaf to True indicates that ClockPage resources will never have
any children.

Without this, the ClockPage resources must have a child or it can only
produce a 404.


https://twistedmatrix.com/documents/current/web/howto/web-in-60/dynamic-dispatch.html
does not have isLeaf = True because it defines getChild for the root class
Calendar

So does not have isLeaf = True because it was written as an .rpy script??
http://twistedmatrix.com/documents/current/web/howto/web-in-60/asynchronous.html

Thank you again,
-Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-web/attachments/20180809/f37c62f5/attachment.html>


More information about the Twisted-web mailing list