[Twisted-web] XMLRPC and keyword arguments

Jean-Paul Calderone exarkun at divmod.com
Mon Mar 10 13:09:19 EDT 2008


On Mon, 10 Mar 2008 10:15:17 -0600, Andrew McNabb <amcnabb at mcnabbs.org> wrote:
>I've made a simple extension to XMLRPC, and I was wondering if it is
>something that I should contribute back to Twisted or if I should keep
>it to myself.  In other words, would others find this useful?
>
>The idea is that RPC methods might need to get at information in the
>request.  For example, an RPC method might need to know what IP address
>the request comes from or it might need to know if HTTP basic
>authentication is set.  I'm sure I could come up with more examples.
>
>Here how it's used:
>
>class SomeXMLRPCClass(XMLRPC):
>    def keywords(self, request):
>        return {'client': request.client}
>
>    def xmlrpc_echo(self, x, **kwds):
>        client = kwds['client']
>        # [do what you need to with client here]
>        return x
>
>Anyway, implementing this is incredibly simple, and I needed it for a
>project I'm working on.  If it would be useful to others, I'd be happy
>to create a ticket and post a patch.

This seems like a slightly round-about API.  What would you think of having
another prefix which included the request as the first argument?  Or the
same prefix could be used and the function could have an attribute indicating
it wants the request.

Jean-Paul



More information about the Twisted-web mailing list