def __getattr__(self, name): # allow directive extension names to work directives = getattr(self.registry, '_directives', {}) c = directives.get(name) if c is None: raise AttributeError(name) c, action_wrap = c if action_wrap: c = action_method(c) # Create a bound method (works on both Py2 and Py3) # http://stackoverflow.com/a/1015405/209039 m = c.__get__(self, self.__class__) return m