code: def determine_hooks(self, controller=None):
          '''
          Determines the hooks to be run, in which order.
  
          :param controller: If specified, includes hooks for a specific
                             controller.
          '''
  
          controller_hooks = []
          if controller:
              controller_hooks = _cfg(controller).get('hooks', [])
              if controller_hooks:
                  return list(
                      sorted(
                          chain(controller_hooks, self.hooks),
                          key=operator.attrgetter('priority')
                      )
                  )
          return self.hookf determine_hooks(self, controller=None):
          '''
          Determines the hooks to be run, in which order.
  
          :param controller: If specified, includes hooks for a specific
                             controller.
          '''
  
          controller_hooks = []
          if controller:
              controller_hooks = _cfg(controller).get('hooks', [])
              if controller_hooks:
                  return list(
                      sorted(
                          chain(controller_hooks, self.hooks),
                          key=operator.attrgetter('priority')
                      )
                  )
          return self.hooks
docs: Determines the hooks to be run, in which order.
  
          :param controller: If specified, includes hooks for a specific
                             controller.