[Zope3-dev] Security Proxy/isinstance

Jim Fulton jim at zope.com
Fri Dec 2 10:35:10 EST 2005


Andres Freund wrote:
> Hi,
> 
> Dominik Huber wrote:
> 
>> You can use zapi.isinstance (zope.security.proxy orig. place). This 
>> function is useful because it works even if the instance is security 
>> proxied.
> 
> I know that from irc but there are two issues:
> -Fixing that in foreign code is dirty and error prone. In my own code i 
> wouldn't have a problem with it.
> 
> -Why not fix it in the proxies if the problem can be solved? Thats the 
> way much more clean way i think. You don't want to learn new ways, if 
> the old ones can be made compatible.
> 
> For now i fixed that through monkey patching, but i don't like that.

This can't be fixed by changing the proxy behavior.  Security proxies
expose a valid __class__ attribute except that it is security proxied.
It isn't valid to change this.  Unfortunately, the standard Python isinstance
requires that the value if the __class__ attribute is a known class
type.  It does this because it uses internal C data structures of types
which it can't get to through a proxy.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Zope3-dev mailing list