proxy for xmlrpc calls

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.
 
F

Fredrik Lundh

Xavier said:
I'm attempting to write a proxy for xmlrpc calls.

why not use the one in the standard library?
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?

you can't determine that.

(and XML-RPC doesn't support attribute access either, so this sounds
like a rather pointless exercise)
I thought about getting the source code from the correct frame, but
I don't think thats a good solution.

getting the source won't help, unless you're willing to violate Python's
execution model.
Any ideas?

stick to the standard.

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top