Hi all, a quick question: how could I (in a python script) get a list of all inherited classes from an object's meta_type? My aim's is to get the first object implementing ObjectManager while going up in the PARENTS hierarchy, whith something like that: parents = request.PARENTS for i in range(len(parents)): if parents[i].meta_type ********: ### if it implements ObjectManagers return parents[i] Ciao Mik
Michele Ruberl wrote:
Hi all, a quick question: how could I (in a python script) get a list of all inherited classes from an object's meta_type? My aim's is to get the first object implementing ObjectManager while going up in the PARENTS hierarchy,
Why parents? ObjectManager isn't a discernable interface, what do you mean by objetc manager? What is the problem you're trying to solve with this algorithm? cheers, Chris
Michele Ruberl wrote at 2003-1-8 18:37 +0100:
a quick question: how could I (in a python script) get a list of all inherited classes from an object's meta_type? My aim's is to get the first object implementing ObjectManager while going up in the PARENTS hierarchy, whith something like that:
parents = request.PARENTS for i in range(len(parents)): if parents[i].meta_type ********: ### if it implements ObjectManagers return parents[i] You cannot get the inherited classes in TTW code (the access would be "object.aq_base.__class__.__bases__; neither "aq_base" nor "__class__" or "__bases__" are availabe in TTW code).
But "OFS.ObjectManager" defines the attribute "isAnObjectManager=1", such you can check for it. Your only problem: you must avoid acquisition. In most cases, "aq_explicit" does this but it is not safe. When you need a safe solution, search the Collector for my "hasattr_unacquired" patch. Dieter
participants (3)
-
Chris Withers -
Dieter Maurer -
Michele Ruberl