Re: Twisted-web Digest, Vol 151, Issue 2
Jason Harrison <[email protected]> Thu, 9 Aug 2018 10:32:24 -0700
| Newsgroups | gmane.comp.python.twisted.web |
|---|---|
| Message-ID | <CAHVLaBEOrTfccmdu_VDzUvM7-22JLBErvBYWay1XNt_GHp5p4Q@mail.gmail.com> |
--===============6081793070327721886== Content-Type: multipart/alternative; boundary="000000000000a2cc6c05730402a8" --000000000000a2cc6c05730402a8 Content-Type: text/plain; charset="UTF-8" On Thu, 9 Aug 2018 at 09:31 am Jean-Paul Calderone < [email protected]> 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 --000000000000a2cc6c05730402a8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_extra"><div><div class=3D"gmail_signat= ure">On Thu, 9 Aug 2018 at 09:31 am Jean-Paul Calderone <<a href=3D"mail= to:[email protected]">[email protected]</a>> wrote:</div= ></div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style= =3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding= -left:1ex"> In the code you posted, DelayedResponse is the root resource.=C2=A0 The roo= t<br> resource *always* has to provide a child resource.=C2=A0 If someone request= s<br> /foo then the child is "foo".=C2=A0 If someone requests "/&q= uot; then the child is "".<br> <br> isLeaf =3D True is a shortcut that stops traversal and uses the current<br> resource as the requested resource.=C2=A0 Without this, DelayedResponse mus= t<br> have a child or it can only produce a 404.<br> <br> Maybe that explains it?=C2=A0 If there are examples in the documentation th= at<br> have root resources with no children and without isLeaf =3D True then perha= ps<br> they are also broken and should be fixed.=C2=A0 If you see any, please poin= t<br> them out.<br><br></blockquote><div><br></div><div>Thank you for the explana= tion! Let's see if I understand your explanation and the variation in t= he examples.</div><div><br></div><div><a href=3D"https://twistedmatrix.com/= documents/current/web/howto/web-in-60/custom-codes.html">https://twistedmat= rix.com/documents/current/web/howto/web-in-60/custom-codes.html</a><br></di= v><div>does not have isLeaf =3D True because it has:</div></div></div><bloc= kquote style=3D"margin:0px 0px 0px 40px;border:none;padding:0px"><div class= =3D"gmail_extra"><div class=3D"gmail_quote"><div><div>root =3D Resource()</= div></div></div></div><div class=3D"gmail_extra"><div class=3D"gmail_quote"= ><div><div>root.putChild(b"buy", PaymentRequired())</div></div></= div></div><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div><div>f= actory =3D Site(root)</div></div></div></div></blockquote><div><br></div><d= iv><a href=3D"https://twistedmatrix.com/documents/current/web/howto/web-in-= 60/dynamic-content.html">https://twistedmatrix.com/documents/current/web/ho= wto/web-in-60/dynamic-content.html</a></div><div>does have isLeaf =3D True = because it does not have a .putChild()=C2=A0</div><div><br></div><div>The e= xplanation about isLeaf could be improved by:</div><div><br></div><blockquo= te style=3D"margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>Sett= ing isLeaf to True indicates that ClockPage resources will never have any c= hildren.</div></div></blockquote><blockquote style=3D"margin:0px 0px 0px 40= px;border:none;padding:0px"><div>Without this, the=C2=A0<span style=3D"font= -size:small;background-color:rgb(255,255,255);text-decoration-style:initial= ;text-decoration-color:initial;float:none;display:inline">ClockPage</span>= =C2=A0resources must have a child or it can only produce a 404.</div></bloc= kquote><div><div><br></div></div><div><a href=3D"https://twistedmatrix.com/= documents/current/web/howto/web-in-60/dynamic-dispatch.html">https://twiste= dmatrix.com/documents/current/web/howto/web-in-60/dynamic-dispatch.html</a>= </div><div>does not have isLeaf =3D True because it defines getChild for th= e root class Calendar</div><div><br></div><div>So=C2=A0<span style=3D"font-= size:small;background-color:rgb(255,255,255);text-decoration-style:initial;= text-decoration-color:initial;float:none;display:inline"><span style=3D"tex= t-decoration-style:initial;text-decoration-color:initial;float:none;display= :inline">does not have isLeaf =3D True because it was written as an .rpy sc= ript??</span></span></div><div><a href=3D"http://twistedmatrix.com/document= s/current/web/howto/web-in-60/asynchronous.html">http://twistedmatrix.com/d= ocuments/current/web/howto/web-in-60/asynchronous.html</a><br></div><div><d= iv style=3D"font-size:small;text-decoration-style:initial;text-decoration-c= olor:initial"><br></div><div style=3D"font-size:small;text-decoration-style= :initial;text-decoration-color:initial">Thank you again,</div><div style=3D= "font-size:small;text-decoration-style:initial;text-decoration-color:initia= l">-Jason</div><br class=3D"gmail-Apple-interchange-newline"></div><div><br= ></div><div><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div><br>= </div></div></div></div></div> --000000000000a2cc6c05730402a8-- --===============6081793070327721886== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KVHdpc3RlZC13 ZWIgbWFpbGluZyBsaXN0ClR3aXN0ZWQtd2ViQHR3aXN0ZWRtYXRyaXguY29tCmh0dHBzOi8vdHdp c3RlZG1hdHJpeC5jb20vY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL3R3aXN0ZWQtd2ViCg== --===============6081793070327721886==--