[Zope3-dev] MessageID as rocks?

Steve Alexander steve@cat-box.net
Wed, 16 Apr 2003 21:39:34 +0200


> Yeah, fixing isinstance() wasn't too painful. ;)
> 
> - In zope/proxy/__init__.py I added a function called
> proxy_compatible_isinstance() which (I believe) mimics what Python 2.3's
> isinstance() does.
> 
> - In zope/tales/tales.py evaluateText(), I call this function and if it
> returns true, I do a getbaseobject() and return the results.  This way
> the talinterpreter gets the actual MessageID instead of the wrapped
> object and then everything from there goes as planned.
> 
> Sound right?

Yes. You could also make MessageIDs implement IMessageID, and you could 
do an implements check on the object.

Or, you could call removeAllProxies from zope.proxy.introspection on the 
thing that might be a messageID.

Or, perhaps you can make messageids immutable by using only slots for 
its slots, storing only simple types in its slots, and providing a 
__setattr__ that doesn't. Or something like that.


> It doesn't seem to gross, so I'm happy with checking this in.

Another easy alternative would be to copy the python 2.3 isinstance code 
into proxy.c, and make it available from there.
The tests can be cribbed from the Python2.3 test suite.

--
Steve Alexander