[Tutor] Overriding Methods

Zach Riggle zachriggle at gmail.com
Mon Jul 14 01:38:44 CEST 2008


I am implementing an application using XML-RPC, and would like to be  
able to differentiate between multiple clients.  The best way to do  
this that I could think of would be to simply pass some unique  
identifier along with each call over XML-RPC.  However, this could get  
to be a bit cumbersome, and I'd rather not have to worry about it  
after setting it once (the unique ID on the client-side, that is).

In my particular situation, all of the exposed functions are actually  
methods of a class that inherits from SimpleXMLRPCServer (just to keep  
things nice and simple).

Example:
class X(SimpleXMLRPCServer:
   def someMethod(self, uniqID, someVal):
     ...
     return foo

I would like to create a similar wrapper for xmlrpclib.ServerProxy  
that automatically fills the 'uniqID' field with each call over XMLRPC.

For example, instead of
conn = ServerProxy(someURL)
conn.someMethod(myUniqID, blah)

I would like to be able to do the following...
conn = ServerProxyWrapper(someURL)
conn.setUniqID(myUniqID)
conn.someMethod(blah)

How would I go about implementing this?

Thanks,
Zach


More information about the Tutor mailing list