Re: [Twisted-Python] Monitoring configuration of twisted calls.

Okay, that seems to work. One more question: We've defined a class called XMLRPCWithRemote that subclasses XMLRPC. Some of the methods are local, others with be called using the Proxy. I tried to wrap the function but I'm getting: exceptions.AttributeError: Deferred instance has no __call__ method This is the code I have for wrapping: def wrapper(*args, **kw): func = self._getProxy(URL["url"], URL["user"], URL["passwd"]).callRemote(remote_method, *args, **kw) result = func(*args, **kw) monitor[functionPath] = True return result return wrapper _getProxy is defined thusly: def _getProxy(self, url, username=None, password=None): log.msg("Get proxy") return Proxy(url, user=username, password=password, allowNone=True, useDateTime=True) So it looks like I'm getting a deferred back from the callRemote, so it appears harder to wrap? I think that's what's going on. I'm guessing the local method doesn't require a deferred, so that's why it works. Is there something obvious I'm missing? I started going down the path of overriding xmlrpc.Proxy or xmlrpc._QueryFactory but I'm not sure that's the simplest way. Thanks a bunch, Steve ----- Original Message ---- From: Jean-Paul Calderone <exarkun@divmod.com> To: Twisted general discussion <twisted-python@twistedmatrix.com> Sent: Thursday, August 28, 2008 4:01:10 PM Subject: Re: [Twisted-Python] Monitoring configuration of twisted calls. On Thu, 28 Aug 2008 06:25:40 -0700 (PDT), Steve Lewis <spiritualmechanic@yahoo.com> wrote:
This is probably the best approach. `_getFunction´ should probably be a public method. Its docstring directs users to override it, which is rather in conflict with it being private. To overcome the problem of the function not actually being called inside `_getFunction´, you just need to apply a wrapper to the function which is looked up. The wrapper can mark the call as successful. For example: def _getFunction(self, functionPath): f = XMLRPC._getFunction(self, functionPath) def wrapper(*a, **kw): result = f(*a, **kw) self._monitor[functionPath] = True return result return wrapper I'd also recommend filing a ticket to make `_getFunction´ public, so that you don't have to rely on a private hook to make this work. Jean-Paul _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

On Thu, 28 Aug 2008 10:22:01 -0700 (PDT), Steve Lewis <spiritualmechanic@yahoo.com> wrote:
The wrapper I gave as an example doesn't handle Deferreds, indeed. Have you worked with Deferreds before? If not, you may want to read some of the documentation about them, eg: http://twistedmatrix.com/projects/core/documentation/howto/defer.html That aside, I don't really understand the modifications you've made. It seems that you're doing an XML-RPC call to get a function object to call to produce a result to give to the XML-RPC client which made a call on to you. Since XML-RPC calls can't result in functions, I don't understand this. Jean-Paul

On Thu, 28 Aug 2008 10:22:01 -0700 (PDT), Steve Lewis <spiritualmechanic@yahoo.com> wrote:
The wrapper I gave as an example doesn't handle Deferreds, indeed. Have you worked with Deferreds before? If not, you may want to read some of the documentation about them, eg: http://twistedmatrix.com/projects/core/documentation/howto/defer.html That aside, I don't really understand the modifications you've made. It seems that you're doing an XML-RPC call to get a function object to call to produce a result to give to the XML-RPC client which made a call on to you. Since XML-RPC calls can't result in functions, I don't understand this. Jean-Paul
participants (2)
-
Jean-Paul Calderone
-
Steve Lewis