[Python-Dev] Evil isinstance()

Brian Quinlan brian@sweetapp.com
Mon, 1 Apr 2002 18:01:03 -0800


Guido wrote:
[xmlrpclib creates attributes on demand]
> Hm.  I didn't know xmlrpc did that, and I think it's pretty unique in
> this respect.  

I've seen other RPC code do this. Some soaplib? objects used to
infinitely recurse, if you repred, them due to a subtle __getattr__ bug.

> It looks like a hack, and one that can only work as
> long as attributes on xmlrpc instances are always supposed to be
> methods.  

I imagine that we are talking about xmlrpclib.Server. This class creates
callable objects, representing remote method calls, when attributes are
requested. This allows for a pretty natural method call syntax e.g.

server = xmlrpclib.Server('http://...')  
server.do_something_remote()
server.do_something_else()

XML-RPC does not have an attribute concept.

> Why didn't you choose to special-case xmlrpc?  It appears
> that introspecting an xmlrpc instance is hopeless anyway...
> (Depending on what you need the introspection for, of course.  You
> haven't told us the whole story.)

It's not necessarily hopeless but getting a list of available methods
(and therefore attribute that should be offered) costs a round-trip and
isn't supported by all XML-RPC servers (like Python's
SimpleXMLRPCServer, for example). 

Cheers,
Brian