[Twisted-Python] perspective introspection

Christopher Armstrong carmstro at twistedmatrix.com
Mon Feb 11 20:51:41 MST 2002


Well, I asked glyph about this earlier, and he said that it's just as
good to have versioned objects instead of publishing interfaces. I'm not
sure what cases versioned objects wouldn't be sufficient enough, so I'm
not sure which is the best route to go.

On Mon, 2002-02-11 at 22:40, Sean Riley wrote:
> other remote object APIs such as COM and CORBA have ways of asking a remote
> object for it's published interface. SOAP also has this with WSDL
> (http://www.w3.org/TR/wsdl).
> 
> implementing a way for pb perspectives to tell consumers about their
> interface seemed like it would be a trivial undertaking - and it was:
> 
> (for twisted.spread.pb):
> 
> from twisted.python import reflect
> 
> def perspective_getInterface(self):
>         """Retrieve the set of perspective methods for this perspective.
>         This allows client to retrieve the "published" external interface
>         for this perspective/service.
> 
>         the result is returned in a dictionary with the keys being the names
>         of the methods for the client to call, and the values a tuple of
>         the names of the arguments to each method.
>         """
>         dict = {}
>         reflect.addMethodNamesToDict(self.__class__, dict, "perspective_")
>         del dict["getInterface"] # remove the perspective_interface method
> (THIS method)
> 
>         # populate args
>         for k in dict.keys():
>             func = self.__class__.__dict__["perspective_%s"%k]
>             l = func.func_code.co_varnames[1:]
>             dict[k] = l
>         return dict
> 
> it would probably even be possible to wrap this up into WSDL if we wanted
> to, for further "enterprise" compatibility...
> 
> it isn't possible for clients to do this introspection on their own as they
> only have a RemoteReference to the perspective object. does this create any
> security holes? is a bad idea for any other reason?
> 
> 
> ----
> "If it's not running programs or fusing atoms, it's just bending space.",
> Ken Macleod
> "That's it, I'm outta here.", Homer Simpson's Brain
> Sean Riley
> sean at ninjaneering.com
> 
> 
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- 
                                Chris Armstrong
                         << radix at twistedmatrix.com >>
                http://twistedmatrix.com/users/carmstro.twistd/





More information about the Twisted-Python mailing list