Commit 69600158 authored by David Johnson's avatar David Johnson

Handle ApplicableMethods declared in parent class on subclass instance.

(Search the MRO of all objects, a bit yucky; could make it faster.)
parent 1188d33f
......@@ -713,9 +713,24 @@ class Applicable(object):
if type(cls) != str:
cls_name = cls.__name__
fqcp = '%s.%s' % (module,cls_name)
if not fqcp in Applicable._OBJECTS:
# Try the slow way: search the MRO hierarchy for each object.
for (_fqcp,_obj) in Applicable._OBJECTS.iteritems():
clshier = inspect.getmro(_obj.__class__)
for _cls in clshier:
print _cls
if _cls.__name__ == cls_name and _cls.__module__ == module:
fqcp = _fqcp
if not fqcp in Applicable._OBJECTS:
raise Exception("no object instance for fully-qualified class %s!"
% (fqcp,))
obj = Applicable._OBJECTS[fqcp]
func = getattr(obj,_func.__name__)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment