I'm trying to wrap my xml-rpc server (python 2.7) and i'm using the code from this post
This is my code:
class XMLRPCWrapperProxy(object):
def __init__(self, wrapped=None):
if wrapped is None:
wrapped = xmlrpclib.ServerProxy('http://xxx.xxx.xxx.xxx:xxxx')
self.tf = wrapped
def __getattr__(self, name):
print "before"
attr = getattr(self.tf, name)
print "after"
return type(self)(attr)
def __call__(self, *args, **kw):
return self.tf(*args, **kw)
server_w = XMLRPCWrapperProxy()
server_w.tf.do_function1()
server_w.tf.do_function2(param1)
server_w.tf.do_function3()
server_w.tf.do_function4(param1)
I want to wrap do_fuxntion...
call but for some reason i can't see the print statements, i think i'm wrapping self.tf and not the call methods, any idea how can i warp any method call?