[Zope-CMF] isinstance on ActionProviderBase
Nicolas Romero
Nicolas.Romero at adp3i.fr
Tue Sep 30 06:09:57 EDT 2003
Hi,
I am developping a product and I have a problem using isinstance on
ActionProviderBase objects. Here is an excerpt of my code :
## start here
from Products.CMFCore.ActionProviderBase import ActionProviderBase
from AccessControl.Role import RoleManager
def getObjectConfigFromZope( self, obj):
d = {}
if isinstance( obj, RoleManager):
d['permissions'] = self.getPermissions( obj)
d['localroles'] = self.getLocalroles( obj)
if isinstance( obj, ActionProviderBase):
d['actions'] = self.getActions( obj)
## end here
Let obj be a CMF tool, for example portal_types, of class TypesTool,
which is defined as
class TypesTool( UniqueObject, OFS.Folder.Folder, ActionProviderBase ):
I don't understand why isinstance(obj,RoleManager) returns 1 [correct],
isinstance( obj,ActionProviderBase) returns 0 [why ?]. If I replace the
latter with issubclass(obj.__class__,ActionProviderBase), it returns 1
[correct].
On the other hand, in Python, I obtain :
$ python
Python 2.1.3 (#1, Jun 11 2003, 11:49:07)
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> class A:
... pass
...
>>> class B(A):
... pass
...
>>> class C:
... pass
...
>>> class D(C,A):
... pass
...
>>> b = B()
>>> isinstance(b, A)
1
>>> d=D()
>>> isinstance(d,A)
1
>>> issubclass(d.__class__,A)
1
>>>
What is the difference between d and obj ?
--
Nicolas Romero, adp3i - 101, rue Bannier 45000 ORLEANS
|
Tél: 02 38 81 06 47 | adp3i <http://www.adp3i.fr>
Fax: 02 38 80 06 31 | Solutions Doméo <http://www.adp3i.net>
More information about the Zope-CMF
mailing list