[Grok-dev] Martian and ExtensionClasses.
regebro at gmail.com
Sun Apr 27 06:55:33 EDT 2008
When writing the changelog for the EventClass support I realized maybe
this was useful for metclasses as well.
So I asked on #python and Thomas Wouters in his useful style of
helpful rudeness recommended that we don't do type(obj) at all, but
that we do
isinstance(obj, ...). So I tried that:
def grokkers(self, name, obj):
obj_type = type(obj)
if isinstance(obj, (type, types.ClassType)):
return self._multi_class_grokker.grokkers(name, obj)
elif isinstance(obj, types.ModuleType):
return self._multi_global_grokker.grokkers(name, obj)
return self._multi_instance_grokker.grokkers(name, obj)
This works with ExtensionClasses, and it is supposed to work with
metaclasses as well.
So question to Martijn: Is there any reason you used type(obj) instead
of isinstance(obj, ...) ? It seems like with this change we don't need
to extend the list of classes.
Lennart Regebro: Zope and Plone consulting.
+33 661 58 14 64
More information about the Grok-dev