Hi, I use custom Zope products written in Python. In several cases, I have to check for published object's class and adapt several front-end parameters according to it. My questions are simple : - is it better to test for "object.meta_type" or "isinstance (object, class)" (concerning performances as well as the possibility to create subclasses) ? - as long as subclasses are not to be created from ZMI but from another backoffice, is it possible to use the same "meta_type" for a class and all it's subclasses ? Thanks, Thierry -- Linux every day, keeps Dr Watson away... http://gpc.sourceforge.net -- http://www.ulthar.net
Thierry FLORAC wrote at 2003-3-24 09:59 +0100:
... - is it better to test for "object.meta_type"
Drawback: no inheritance check
or "isinstance (object, class)"
Drawback: you usually need "object.aq_base". It's more expensive than a simple "meta_type" check. Dieter
On Monday 24 March 2003 19:53, Dieter Maurer wrote:
Thierry FLORAC wrote at 2003-3-24 09:59 +0100:
... - is it better to test for "object.meta_type"
Drawback:
no inheritance check
or "isinstance (object, class)"
Drawback:
you usually need "object.aq_base".
It's more expensive than a simple "meta_type" check.
OK. But is it possible to give the same meta_type to a base class and it's inherited ones (as long as I have other properties to distinguish instances of these classes) ?? Thanks, Thierry
Thierry FLORAC wrote:
OK. But is it possible to give the same meta_type to a base class and it's inherited ones (as long as I have other properties to distinguish instances of these classes) ??
Yes, but it may not be a good idea... cheers, Chris
participants (3)
-
Chris Withers -
Dieter Maurer -
Thierry FLORAC