[Twisted-web] Adding service to virtual path

Eric Chamberlain Eric.Chamberlain at zonarsystems.com
Thu Oct 21 16:17:36 EDT 2010

I'm trying to add a single service to a virtual path like http://localhost:8080/geospatial/geocoder/XMLRPC.

Version info:
Twisted: 9.0
Python: 2.6

The following code does not work:

root = resource.Resource()
srv = XMLRPCGeocoder()
root.putChild("geospatial/geocoder/XMLRPC", srv)

When I attempt to access the service, twisted gives the following error:
Request failed: <ProtocolError for localhost:8080/geospatial/geocoder/XMLRPC: 404 Not Found>

If I use the following code, and change the client to point only to localhost:8080/XMLRPC, it _does_ work:

root.putChild("XMLRPC", srv)

The docs say something about using putChild.putChild... so I tried the following:

root.putChild("geospatial", None).putChild("geocoder", None).putChild("XMLRPC", srv)

The problem is Resource.putChild _always_ returns None!  Even the following, which is the working version:
print root.putChild("XMLRPC", srv) # Prints None too

Looking at twisted.web.resource.Resource's source code, all it does is add the path to a hash array and returns nothing...

It seems like such a simple thing to do!  Thanks for your help!

Confidentiality Notice: This e-mail may contain proprietary information some of which may be legally privileged. It is for the intended recipient(s) only. If you believe that it has been sent to you in error, please notify the sender by reply e-mail and delete the message. Any disclosure, copying, distribution or use of this information by someone other than the intended recipient(s) is prohibited and may be unlawful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20101021/1ac8e4dd/attachment.htm 

More information about the Twisted-web mailing list