[Twisted-Python] XMLRPC Class in HTTP Server.

I'm not sure how the twisted web server works (I'm a new guy around here!), but it looks like your dictionary, pages, maps url's to callables. But MyConverterXMLRPCClass() is an instance, that is not callable (no __call__ method). I think what you want to do is something like this -> '/xmlrpc_converter': MyConverterXMLRPCClass().xmlrpc_mymethod1 ^^ Should get you past the __call__ error you're getting. HTH! jw On 7/6/07, Daniel de la Cuesta <daniel.cuesta@iavante.es> wrote:
-- "Government does not solve problems; it subsidizes them." Ronald Reagan

Daniel de la Cuesta wrote:
Ok, but this is not exactly what I want.
The xml-rpc server is a web resource node, so to make things work, you need to call the render() method on your xml-rpc instance, so in your url map, instead of... MyConverterXMLRPCClass() use... MyConverterXMLRPCClass().render to store a bound reference to the render method and then all you need to do is call that and pass it the request object. The render method will take care of setting up deferreds to write the response or any errors back to the client. -- Jason Fritcher Senior Software Engineer Core Infrastructure Services & Strategy Earthlink, Inc fritcher@corp.earthlink.net

Wasn't going to reply to this, for reasons which will be obvious momentarily, but I haven't seen a correct reply yet, so... On Fri, 06 Jul 2007 09:46:38 +0200, Daniel de la Cuesta <daniel.cuesta@iavante.es> wrote:
You probably want to direct future questions on this topic to the twisted-web mailing list, where you'll get more attention from people more actively doing web things.
HTTP POST is probably a better way to upload files, in general. MIME-ish encoding is a bit easier and has less overhead than base64 encoding.
Rarely is it correct to subclass Request. You can probably just discard all of the above code. Aside from that, I don't know what the `pages' attribute is. I don't think anything pays any attention to it.
This part looks okay.
I don't know how a MyConverterXMLRPCClass got called. I suppose you have some more code that you didn't include in this message which looks at the pages dictionary on the request object and does something with them. Whatever it is, I guess it isn't correct. ;) Instead, what you should do is define a root resource which has MyConverterXMLRPCClass as a child at the "xmlrpc_converter" segment. You can do this pretty easily using the basic Resource class in twisted.web: from twisted.web.resource import Resource from twisted.web.server import Site from twisted.internet import reactor root = Resource() root.putChild('xmlrpc_converter', MyConverterXMLRPCClass()) site = Site(root) reactor.listenTCP(8080, site) The Resource class is implemented to keep track of child resources added to it with putChild so that when a request comes in for one of them, it gives back the appropriate one and URL traversal or page rendering can continue. Hope this helps, Jean-Paul

I'm not sure how the twisted web server works (I'm a new guy around here!), but it looks like your dictionary, pages, maps url's to callables. But MyConverterXMLRPCClass() is an instance, that is not callable (no __call__ method). I think what you want to do is something like this -> '/xmlrpc_converter': MyConverterXMLRPCClass().xmlrpc_mymethod1 ^^ Should get you past the __call__ error you're getting. HTH! jw On 7/6/07, Daniel de la Cuesta <daniel.cuesta@iavante.es> wrote:
-- "Government does not solve problems; it subsidizes them." Ronald Reagan

Daniel de la Cuesta wrote:
Ok, but this is not exactly what I want.
The xml-rpc server is a web resource node, so to make things work, you need to call the render() method on your xml-rpc instance, so in your url map, instead of... MyConverterXMLRPCClass() use... MyConverterXMLRPCClass().render to store a bound reference to the render method and then all you need to do is call that and pass it the request object. The render method will take care of setting up deferreds to write the response or any errors back to the client. -- Jason Fritcher Senior Software Engineer Core Infrastructure Services & Strategy Earthlink, Inc fritcher@corp.earthlink.net

Wasn't going to reply to this, for reasons which will be obvious momentarily, but I haven't seen a correct reply yet, so... On Fri, 06 Jul 2007 09:46:38 +0200, Daniel de la Cuesta <daniel.cuesta@iavante.es> wrote:
You probably want to direct future questions on this topic to the twisted-web mailing list, where you'll get more attention from people more actively doing web things.
HTTP POST is probably a better way to upload files, in general. MIME-ish encoding is a bit easier and has less overhead than base64 encoding.
Rarely is it correct to subclass Request. You can probably just discard all of the above code. Aside from that, I don't know what the `pages' attribute is. I don't think anything pays any attention to it.
This part looks okay.
I don't know how a MyConverterXMLRPCClass got called. I suppose you have some more code that you didn't include in this message which looks at the pages dictionary on the request object and does something with them. Whatever it is, I guess it isn't correct. ;) Instead, what you should do is define a root resource which has MyConverterXMLRPCClass as a child at the "xmlrpc_converter" segment. You can do this pretty easily using the basic Resource class in twisted.web: from twisted.web.resource import Resource from twisted.web.server import Site from twisted.internet import reactor root = Resource() root.putChild('xmlrpc_converter', MyConverterXMLRPCClass()) site = Site(root) reactor.listenTCP(8080, site) The Resource class is implemented to keep track of child resources added to it with putChild so that when a request comes in for one of them, it gives back the appropriate one and URL traversal or page rendering can continue. Hope this helps, Jean-Paul
participants (4)
-
Daniel de la Cuesta
-
Jaime Wyant
-
Jason Fritcher
-
Jean-Paul Calderone