[Twisted-Python] Problem with XMLRPC resource wrapped with guard basic auth

asset asset at impactdamage.com
Tue Oct 6 20:00:19 EDT 2009

 Using the current trunk r27366 (which is after #4014 fixed a related 
issue), I am having trouble with an implementation of web.guard wrapped 
XMLRPC.  This is a new test implementation to expose both a soap and xmlrpc 
interface.  SOAP works, but xmlrpc throws UnsupportedMethod POST.

Here is my test code, can anybody tell me if im doing something wrong?  
Again, /soap works, but /rpc2 freaks on the POST method being unavailable.

###### test-script.py

from zope.interface import implements
from twisted.internet import reactor
from twisted.web.resource import IResource, Resource
from twisted.web import server, guard
from twisted.cred.portal import IRealm
from twisted.python import log

from zope.interface import implements

from twisted.python import log
from twisted.internet import reactor
from twisted.web import server, resource, guard, xmlrpc, soap
from twisted.cred.portal import IRealm, Portal
from twisted.cred.checkers import InMemoryUsernamePasswordDatabaseDontUse

import sys

def getQuote():
    return "Victory to the burgeois, you capitalist swine!"

class XMLRPCQuoter(xmlrpc.XMLRPC):
    def xmlrpc_quote(self):
        return getQuote()

class SOAPQuoter(soap.SOAPPublisher):
    def soap_quote(self):
        return getQuote()

class WebServicesRealm(object):

    def requestAvatar(self, avatarId, mind, *interfaces):
        if resource.IResource in interfaces:
            node = resource.Resource()
            node.putChild("rpc2", XMLRPCQuoter())
            node.putChild("soap", SOAPQuoter())
            return resource.IResource, node, lambda: None
        raise NotImplementedError()

if __name__ == "__main__":

   checker = [InMemoryUsernamePasswordDatabaseDontUse(foo='bar')]
   webServicesWrapper = 
guard.HTTPAuthSessionWrapper(Portal(WebServicesRealm(), checker),

   reactor.listenTCP(9999, server.Site(webServicesWrapper))


http://localhost:9999/soap *good*
http://localhost:9999/rpc2 *bad; POST isnt an allowed method*



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20091006/091dc8b1/attachment.htm 

More information about the Twisted-Python mailing list