[Zope-Coders] ZopeVersionControl

Florent Guillaume fg@nuxeo.com
Fri, 21 Feb 2003 14:23:11 +0000 (UTC)


Magnus Heino  <magnus.heino@pleon.sigma.se> wrote:
> Then Shane made some changes:

I was reading the diff for that change
(http://cvs.zope.org/Products/ZopeVersionControl/ZopeRepository.py.diff?r1=1.2&r2=1.3),
and Shane wrote:

   try:
       v = isinstance(object, ObjectManager)
   except TypeError:
       # Python 2.1 isinstance() dislikes ExtensionClass instances.
       # This is an adequate workaround.
       v = 0

As I depend on this in some of my code, I'm wondering, in what case does
this fail? I haven't found one:

Python 2.1.3 (#1, Sep 19 2002, 13:15:46)
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import Zope
>>> from OFS.ObjectManager import ObjectManager
>>> a=ObjectManager()
>>> isinstance(a, ObjectManager)
1
>>> class B(ObjectManager):
...   pass
...
>>> b=B()
>>> isinstance(b, ObjectManager)
1
>>> class C:
...   pass
...
>>> class D(C, ObjectManager):
...   pass
...
>>> d=D()
>>> isinstance(d, ObjectManager)
1
>>> class E(ObjectManager, C):
...   pass
...
>>> e=E()
>>> isinstance(e, ObjectManager)
1

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com