def register(self, name, func, weight=0):
        """
        Register a function to a hook.  The function will be called, in order
        of weight, when the hook is run.

        :param name: The name of the hook to register too.
            I.e. ``pre_setup``, ``post_run``, etc.
        :param func:    The function to register to the hook.  This is an
            *un-instantiated*, non-instance method, simple function.
        :param weight:  The weight in which to order the hook function.
        :type weight: ``int``

        Usage:

        .. code-block:: python

            from cement.core.foundation import CementApp

            def my_hook_func(app):
                # do something with app?
                return True

            with CementApp('myapp') as app:
                app.hook.define('my_hook_name')
                app.hook.register('my_hook_name', my_hook_func)

        """
        if name not in self.__hooks__:
            LOG.debug("hook name '%s' is not defined! ignoring..." % name)
            return False

        LOG.debug("registering hook '%s' from %s into hooks['%s']" %
                  (func.__name__, func.__module__, name))

        # Hooks are as follows: (weight, name, func)
        self.__hooks__[name].append((int(weight), func.__name__, func))
dataset/ETHPy150Open datafolklabs/cement/cement/core/hook.py/HookManager.register/original