At 02:10 AM 10/28/99 +1000, Ben Leslie wrote:
Below is a snippet of code which is the closet I've come to getting this to work. Unfortunately this totally kills and persistance
def __getattr__(self, name): if name in ('ages', 'add', 'multiply'): myserv = xmlrpclib.Server(self.server) return (getattr(myserv,name)) else: return Acquisition.Acquired
By the way, just as a postscript to my explanation of how to do this with __of__, keep in mind that just because an object is persistent doesn't mean it can't have non-persistent sub-objects... for example: class RPCMethodCollection: def __init__(self,server,allowed_names): self.server = server self. def __getattr__(self,name): if name in self.allowed_names: myserv = xmlrpclib.Server(self.server) return (getattr(myserv,name)) raise AttributeError,name Then have XMLRPCClient add a "methods" attribute that is an instance of RPCMethodCollection. You can now say things like: <!--#with "someserver.methods"--> <!--#call "add(2,3)"--> <!--#/with--> Which leads to my final point, namely that maybe, instead of making the client object provide all the methods, maybe from a design perspective it would make more sense to have very lightweight "XMLRPCMethod" objects which talk to an "XMLRPCServer" object. This allows you to have much more fine-grained permissions control on use of the methods, and it'll be easier to call them from DTML anyhow.