X
Xavier
I'm attempting to write a proxy for xmlrpc calls.
I'm starting from this code;
class MagicObject:
def __call__(self,*args,**kwargs):
return MagicObject.__dict__['_stop'](self,self.n,*args,**kwargs)
def __getattr__(self,name):
if name in ('__str__','__repr__'): return lambda:'instance of
%s at %s' % (str(self.__class__),id(self))
if not self.__dict__.has_key('n'):self.n=[]
self.n.append(name)
return self
def _stop(self,n,*args,**kwargs):
self.n=[]
return self.default(n,*args,**kwargs)
def default(self,n,*args,**kwargs):
return 'stop',n,args,kwargs
################################################################
('stop', ['beubeb', 'zzzzz'], (1, 2, 3), {'a': 'bbb'})
I did not write this, the source is here:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/435757
I want to expand this to do something like;
Then on the last __getattr__ send a call over xmlrpc.
How do I determine when the last __getattr__ will be?
With method calls you know to send a call on xmlrpc when you hit
__call__. But if you're dealing with a getting nested attributes
what do you do? How do I know when there are no more attributes?
I thought about getting the source code from
the correct frame, but I don't think thats a good solution.
Any ideas?
Thanks in advance.
I'm starting from this code;
class MagicObject:
def __call__(self,*args,**kwargs):
return MagicObject.__dict__['_stop'](self,self.n,*args,**kwargs)
def __getattr__(self,name):
if name in ('__str__','__repr__'): return lambda:'instance of
%s at %s' % (str(self.__class__),id(self))
if not self.__dict__.has_key('n'):self.n=[]
self.n.append(name)
return self
def _stop(self,n,*args,**kwargs):
self.n=[]
return self.default(n,*args,**kwargs)
def default(self,n,*args,**kwargs):
return 'stop',n,args,kwargs
################################################################
('stop', ['beubeb', 'zzzzz'], (1, 2, 3), {'a': 'bbb'})
I did not write this, the source is here:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/435757
I want to expand this to do something like;
Then on the last __getattr__ send a call over xmlrpc.
How do I determine when the last __getattr__ will be?
With method calls you know to send a call on xmlrpc when you hit
__call__. But if you're dealing with a getting nested attributes
what do you do? How do I know when there are no more attributes?
I thought about getting the source code from
the correct frame, but I don't think thats a good solution.
Any ideas?
Thanks in advance.