Adding service to virtual path
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.
On Thu, Oct 21, 2010 at 01:17:36PM -0700, Eric Chamberlain wrote:
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>
You should put a resource for each component of the url: root = resource.Resource() geospatial = resource.Resource() root.putChild('geospatial', geospatial) geocoder = resource.Resource() geospatial.putChild('geocoder', geocoder) xmlrpc = XMLRPCGeocoder() geocoder.putChild('XMLRPC', xmlrpc) I didn't double checked, but I am pretty sure that this will works.
Looking at twisted.web.resource.Resource's source code, all it does is add the path to a hash array and returns nothing...
Yes, putChild does this, but this is not how path traversal works. The path is splitted in segments which are harvested one after the other until a resource is returned. m. -- Dalle virtù che si esigono in un domestico, l'Eccellenza Vostra conosce molti padroni degni d'esser servitori? -- Pierre Augustin Caron de Beaumarchais
That was it. If you lived near by I'd buy you a beer. Thank you! On Oct 21, 2010, at 1:47 PM, Marco Giusti wrote: On Thu, Oct 21, 2010 at 01:17:36PM -0700, Eric Chamberlain wrote: 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> You should put a resource for each component of the url: root = resource.Resource() geospatial = resource.Resource() root.putChild('geospatial', geospatial) geocoder = resource.Resource() geospatial.putChild('geocoder', geocoder) xmlrpc = XMLRPCGeocoder() geocoder.putChild('XMLRPC', xmlrpc) I didn't double checked, but I am pretty sure that this will works. Looking at twisted.web.resource.Resource's source code, all it does is add the path to a hash array and returns nothing... Yes, putChild does this, but this is not how path traversal works. The path is splitted in segments which are harvested one after the other until a resource is returned. m. -- Dalle virtù che si esigono in un domestico, l'Eccellenza Vostra conosce molti padroni degni d'esser servitori? -- Pierre Augustin Caron de Beaumarchais _______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com<mailto:Twisted-web@twistedmatrix.com> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web ________________________________ 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.
On Thu, Oct 21, 2010 at 02:20:41PM -0700, Eric Chamberlain wrote:
That was it. If you lived near by I'd buy you a beer. Thank you!
I appreciate the thought. :) m. -- Cosa volete? Questo diavolo d'uomo ha sempre le tasche ripiene di argomenti irresistibili. -- Pierre Augustin Caron de Beaumarchais
participants (2)
-
Eric Chamberlain
-
Marco Giusti