code: def pluggable(method):
      
      def wrapped(self, *args, **kwargs):
          if hasattr(self, "_plugins"):
              # call the last plugin, it may call the previous via self.parent.method
              # creating a call call chain
              return getattr(self._plugins[-1], method.__name__)(*args, **kwargs)
          else:
              return method(self, *args, **kwargs)
      wrapped.original = method
      return wrapped
docs: Mark a class method as extendable with plugins.