getChild in python3

Nathaniel Haggard <[email protected]> Tue, 5 Nov 2019 13:20:59 -0700
Newsgroups gmane.comp.python.twisted.web
Message-ID <CAAbnaHb_vXXTmRaye6VQr_3tR4d5XZZRk00ms8nOyHh034Arsw@mail.gmail.com>
--===============1716495820970492173==
Content-Type: multipart/alternative; boundary="00000000000044be3f05969f2cba"

--00000000000044be3f05969f2cba
Content-Type: text/plain; charset="UTF-8"

# This code doesn't call getChild in python3, but it does in python2
(python2 throws AttributeError, but python3 doesn't) with "curl
http://127.0.0.1:8803/bug/a" and Twisted==19.7.0 with python3.5.2:

from twisted.application import internet, service, strports
from twisted.web.resource import Resource
from twisted.web.server import Site
from twisted.internet import reactor
from twisted.python import log


from twisted.web.resource import Resource



class R(Resource):
    allowedMethods=('GET',)
    def getChild(self, name, request):
        pass


r = Resource()
r.putChild('bug', R())

application = service.Application('web')
site = Site(r)
sc = service.IServiceCollection(application)
i = strports.service("tcp:8803", site)
i.setServiceParent(sc)

--00000000000044be3f05969f2cba
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div># This code doesn&#39;t call getChild in python3, but=
 it does in python2 (python2 throws AttributeError, but python3 doesn&#39;t=
) with &quot;curl <a href=3D"http://127.0.0.1:8803/bug/a">http://127.0.0.1:=
8803/bug/a</a>&quot; and Twisted=3D=3D19.7.0 with python3.5.2:</div><div><b=
r></div>from twisted.application import internet, service, strports<br>from=
 twisted.web.resource import Resource<br>from twisted.web.server import Sit=
e<br>from twisted.internet import reactor<br>from twisted.python import log=
<br><br><br>from twisted.web.resource import Resource<br><br><br><br>class =
R(Resource):<br>=C2=A0 =C2=A0 allowedMethods=3D(&#39;GET&#39;,)<br>=C2=A0 =
=C2=A0 def getChild(self, name, request):<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pa=
ss<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 <br><br>r =3D Resource()<br>r.putChild(&#=
39;bug&#39;, R())<br><br>application =3D service.Application(&#39;web&#39;)=
<br>site =3D Site(r)<br>sc =3D service.IServiceCollection(application)<br>i=
 =3D strports.service(&quot;tcp:8803&quot;, site)<br>i.setServiceParent(sc)=
<br><div><br></div></div>

--00000000000044be3f05969f2cba--

--===============1716495820970492173==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KVHdpc3RlZC13
ZWIgbWFpbGluZyBsaXN0ClR3aXN0ZWQtd2ViQHR3aXN0ZWRtYXRyaXguY29tCmh0dHBzOi8vdHdp
c3RlZG1hdHJpeC5jb20vY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL3R3aXN0ZWQtd2ViCg==

--===============1716495820970492173==--