[EMAIL PROTECTED] wrote:

> Then the client code can get the value of i like this:
> c = xmlrpclib.ServerProxy("address")
> c.geti()
> 
> but why can't I get the value of i like this?
> 
> c.i

you can't.  the XML-RPC protocol only supports method calls, not 
attribute accesses.

 > How can I implement such behaviour?

you could use reflection to automatically wrap attributes on the server 
side; e.g.

     class foo:
        x = 10
        # generic getter
        def __getattr__(self, key):
            if not key.startswith("get_"):
                raise AttributeError
            value = getattr(self, key[4:])
            return lambda: value

     f = foo()
     print f.x
     print f.get_x()

</F>

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to