SimpleXMLRPCServer and client address

Jean-Michel Pichavant jeanmichel at sequans.com
Wed Feb 10 20:36:15 EST 2010


Jordan Apgar wrote:
> I'm trying to right a server that needs specific information for each
> client accessing it.  The easiest way I could think of doing this is
> keeping this information based on ip address (the information is only
> valid for a short time).  I know there is no was to get the client's
> address directly and have seen a few examples of subclassing the
> SimpleXMLRPCServer like this:
>
> class RPCServer(SimpleXMLRPCServer):
>
> def _dispatch(self, method, params):
> """Extend dispatch, adding client info to some parameters."""
> if method in ({my list of methods I needed client address}):
> return SimpleXMLRPCServer._dispatch(self, method,
> params+(self.client_address,))
> return SimpleXMLRPCServer._dispatch(self, method, params);
>
>
> but to be honest I don't understand what's going on there or how to
> use it.  Would anyone be able to explain this to me?
>   
I don't know exactly what you are trying to do, but if your server 
requires informations from the client, it would be better to ask 
explicitly the client for those informations.
For instance, if a method requires te client IP address, then the IP 
address is definitely a parameter of the method.

JM



More information about the Python-list mailing list