RE: [Twisted-Python] Newbie:XMLRPC Server as plugin?

Thanks Itamar. I've been reviewing the howto and have that working. My next step, however, was to turn that example into an actual plugin following the QuoteD plugin example which has three parts: - quoters.py => contains business logic - quoteproto.py => contains the protocol definition - quotetap.py => application interface/wrapper My problem is coming up with the xmlrpc equivalent of quoteproto.py which looks like this: from twisted.internet.protocol import Factory, Protocol from twisted.internet.app import Application class QOTD(Protocol): def connectionMade(self): self.transport.write(self.factory.quoter.getQuote()+'\r\n') self.transport.loseConnection() class QOTDFactory(Factory): protocol = QOTD def __init__(self, quoter): self.quoter = quoter What I can't figure out what this should look like for an xmlrpc server. It appears (to me at least) that a fundamental function of the factory method is to set the protocol. But I don't know what this should be for xml-rpc and since twisted appears to do the right thing already, I don't really want to rewrite the connectionMade, etc. methods. I suppose the core issue is that in order to create a plugin I need to call: app.listenTCP(port, factory) and I don't know what factory object to pass or how to get it. Thanks, -steve Steve Nesbitt Senior Configuration Manager The Cobalt Group snesbitt@cobaltgroup.com -----Original Message----- From: Itamar Shtull-Trauring [mailto:itamar@itamarst.org] Sent: Thursday, September 18, 2003 10:10 AM To: twisted-python@twistedmatrix.com Subject: Re: [Twisted-Python] Newbie:XMLRPC Server as plugin? On Thu, 18 Sep 2003 09:47:40 -0700 "Nesbitt, Steve" <snesbitt@cobaltgroup.com> wrote:
I would like to implement an XML-RPC server as a plugin (using the QuoteD how-to as an example) and can't figure out how to do so. In particular I don't understand how to create the protocol created as part of the factory.
Protocols are created by the factory when the port you are listening gets an incoming connection - the factory's buildProtocol is called and the resulting protocol is connected to the transport for the new connection. In any case, Twisted already has a nice XML-RPC server framework, documented at http://twistedmatrix.com/documents/howto/xmlrpc - it should support anything you might want to do with a XML-RPC server. -- Itamar Shtull-Trauring http://itamarst.org/ Available for Python & Twisted consulting _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python This e-mail transmission contains information intended only for the use of the recipient(s) named above. Further, it contains information that may be privileged and confidential. If you are not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this message (including any attachments) is strictly prohibited. If you have received this e-mail in error, please notify the sender by reply e-mail and then delete this message from your mail system. Thank you for your compliance.

On Thu, 18 Sep 2003 10:27:12 -0700 "Nesbitt, Steve" <snesbitt@cobaltgroup.com> wrote:
What I can't figure out what this should look like for an xmlrpc server. It appears (to me at least) that a fundamental function of the factory method is to set the protocol. But I don't know what this should be for xml-rpc and since twisted appears to do the right thing already, I don't really want to rewrite the connectionMade, etc. methods.
You don't need to implement a factory or protocol, since the framework already implements them for you. You just need to subclass XMLRPC and run it as shown. You could of course have a generic business logic object that the XML-RPC interface acts as an interface to. Writing factories and protocols is only necessary if you are implementing a new protocol. HTTP is already implemented for you, so you need not bother :) -- Itamar Shtull-Trauring http://itamarst.org/ Available for Python & Twisted consulting
participants (2)
-
Itamar Shtull-Trauring
-
Nesbitt, Steve