[Twisted-Python] Get IP of connecting client in XMLRPC server
![](https://secure.gravatar.com/avatar/a6fc2fa7e8cbb8baaa4f84ac492f71dc.jpg?s=120&d=mm&r=g)
Hello, On 18 May 2004, the following message was posted to this mailinglist: Jp Calderone exarkun at divmod.com wrote:
def xmlrpc_whatIsMyAddress(self): return self.transport.getPeer().host
xmlrpc
method can anyone help me with this?
This solution didn't work because 'transport' isn't a property of the Example class. I'm currently in the process of changing from a customized SimpleXMLRPCServer to a twisted XMLRPC server solution and I need to insert the client IP into the attributes passed to the called xmlrpc method. Anyone who knows the answer and is willing to share the info? Regards, Remy
![](https://secure.gravatar.com/avatar/d7875f8cfd8ba9262bfff2bf6f6f9b35.jpg?s=120&d=mm&r=g)
On Fri, 2004-06-11 at 09:34, Remy C. Cool wrote:
The render() method of the XMLRPC class has access to the request object, which may have request.getPeer() or request.transport.getPeer(). -- Itamar Shtull-Trauring http://itamarst.org
![](https://secure.gravatar.com/avatar/a6fc2fa7e8cbb8baaa4f84ac492f71dc.jpg?s=120&d=mm&r=g)
On Friday 11 June 2004 16:35, Itamar Shtull-Trauring wrote:
Thanks for the answer. The following works, but is this a 'twisted' way to go? class Examle(xmlrpc.XMLRPC): """An example object to be published.""" def _getPeerAddress(self): return self.request.getClientIP() def render(self, request): self.request = request xmlrpc.XMLRPC.render(self, request) Remy
![](https://secure.gravatar.com/avatar/b29e55b8ee1f8e6be6d16c479ac478b8.jpg?s=120&d=mm&r=g)
On 06/11/04 16:56, Remy C. Cool wrote:
Just for the record, this is the way to go (guess it was implemented later): from twisted.web import xmlrpc class Examle(xmlrpc.XMLRPC): @xmlrpc.withRequest def xmlrpc_whatIsMyAddress(self,request): return request.transport.getPeer().host
![](https://secure.gravatar.com/avatar/d7875f8cfd8ba9262bfff2bf6f6f9b35.jpg?s=120&d=mm&r=g)
On Fri, 2004-06-11 at 09:34, Remy C. Cool wrote:
The render() method of the XMLRPC class has access to the request object, which may have request.getPeer() or request.transport.getPeer(). -- Itamar Shtull-Trauring http://itamarst.org
![](https://secure.gravatar.com/avatar/a6fc2fa7e8cbb8baaa4f84ac492f71dc.jpg?s=120&d=mm&r=g)
On Friday 11 June 2004 16:35, Itamar Shtull-Trauring wrote:
Thanks for the answer. The following works, but is this a 'twisted' way to go? class Examle(xmlrpc.XMLRPC): """An example object to be published.""" def _getPeerAddress(self): return self.request.getClientIP() def render(self, request): self.request = request xmlrpc.XMLRPC.render(self, request) Remy
![](https://secure.gravatar.com/avatar/b29e55b8ee1f8e6be6d16c479ac478b8.jpg?s=120&d=mm&r=g)
On 06/11/04 16:56, Remy C. Cool wrote:
Just for the record, this is the way to go (guess it was implemented later): from twisted.web import xmlrpc class Examle(xmlrpc.XMLRPC): @xmlrpc.withRequest def xmlrpc_whatIsMyAddress(self,request): return request.transport.getPeer().host
participants (3)
-
Attila Nagy
-
Itamar Shtull-Trauring
-
Remy C. Cool