how to know if an object is an objectmanager
Hi, I'm writing something generic in a python script which has to test if an object is an objectmanager or not, since I want it to work with Folders but also with user defined types which inherit from objectmanager. How can I do that ? thanks. Jerome Alet - alet@unice.fr - http://cortex.unice.fr/~jerome Fac de Medecine de Nice http://wwwmed.unice.fr Tel: (+33) 4 93 37 76 30 Fax: (+33) 4 93 53 15 15 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE
Hi, You can use the Python builtin issubclass : ex : if issubclass(object.__class__, ObjectManager): xxx Hope this helps, Regards, P.-J. Jerome Alet wrote:
Hi,
I'm writing something generic in a python script which has to test if an object is an objectmanager or not, since I want it to work with Folders but also with user defined types which inherit from objectmanager.
How can I do that ?
thanks.
Jerome Alet - alet@unice.fr - http://cortex.unice.fr/~jerome Fac de Medecine de Nice http://wwwmed.unice.fr Tel: (+33) 4 93 37 76 30 Fax: (+33) 4 93 53 15 15 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- If the only tool you have is a hammer, you tend to see every problem as a nail. Si la unica herramita te tienes es un martillo, tendras tendancia a ver cada problema como un clavo. Wenn Ihnen als einziges Werkzeug ein Hammer zur Verfügung steht, neigen Sie dazu, jedes Problem als Nagel zu betrachten. Si le seul outil dont vous disposez est un marteau, vous avez tendance à voir chaque problème comme un clou. --Abraham Maslow
On Thu, 3 May 2001, Pierre-Julien Grizel wrote:
You can use the Python builtin issubclass : ex : if issubclass(object.__class__, ObjectManager): xxx
Jerome Alet wrote:
I'm writing something generic in a python script
This doesn't work in a python script (name starting with "_"). thanks anyway. Jerome Alet
Jerome Alet wrote:
Hi,
I'm writing something generic in a python script which has to test if an object is an objectmanager or not, since I want it to work with Folders but also with user defined types which inherit from objectmanager.
How can I do that ?
thanks.
Folderish objects (based on ObhectManager) have an attribute, isPrincipiaFolderish. Just test for this property as in: if getattr(ob, 'isPrincipiaFolderish', 0): or <dtml-if name="isPrincipiaFolderish"> hth -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
participants (3)
-
Casey Duncan -
Jerome Alet -
Pierre-Julien Grizel