code: def add(self, name, func):
          ''' Attach a callback to a hook. '''
          if name not in self.hooks:
              raise ValueError("Unknown hook name %s" % name)
          was_empty = self._empty()
          self.hooks[name].append(func)
          if self.app and was_empty and not self._empty(): self.app.reset(f add(self, name, func):
          ''' Attach a callback to a hook. '''
          if name not in self.hooks:
              raise ValueError("Unknown hook name %s" % name)
          was_empty = self._empty()
          self.hooks[name].append(func)
          if self.app and was_empty and not self._empty(): self.app.reset()
docs: Attach a callback to a hook.