def register(self, handler_obj):
        """
        Register a handler object to a handler.  If the same object is already
        registered then no exception is raised, however if a different object
        attempts to be registered to the same name a ``FrameworkError`` is
        raised.

        :param handler_obj: The uninstantiated handler object to register.
        :raises: :class:`cement.core.exc.InterfaceError`
        :raises: :class:`cement.core.exc.FrameworkError`

        Usage:

        .. code-block:: python

            class MyDatabaseHandler(object):
                class Meta:
                    interface = IDatabase
                    label = 'mysql'

                def connect(self):
                    # ...

            app.handler.register(MyDatabaseHandler)

        """

        orig_obj = handler_obj

        # for checks
        obj = orig_obj()

        if not hasattr(obj._meta, 'label') or not obj._meta.label:
            raise exc.InterfaceError("Invalid handler %s, " % orig_obj +
                                     "missing '_meta.label'.")
        if not hasattr(obj._meta, 'interface') or not obj._meta.interface:
            raise exc.InterfaceError("Invalid handler %s, " % orig_obj +
                                     "missing '_meta.interface'.")

        # translate dashes to underscores
        orig_obj.Meta.label = re.sub('-', '_', obj._meta.label)
        obj._meta.label = re.sub('-', '_', obj._meta.label)

        handler_type = obj._meta.interface.IMeta.label
        LOG.debug("registering handler '%s' into handlers['%s']['%s']" %
                  (orig_obj, handler_type, obj._meta.label))

        if handler_type not in self.__handlers__:
            raise exc.FrameworkError("Handler type '%s' doesn't exist." %
                                     handler_type)
        if obj._meta.label in self.__handlers__[handler_type] and \
                self.__handlers__[handler_type][obj._meta.label] != obj:
            raise exc.FrameworkError("handlers['%s']['%s'] already exists" %
                                     (handler_type, obj._meta.label))

        interface = self.__handlers__[handler_type]['__interface__']
        if hasattr(interface.IMeta, 'validator'):
            interface.IMeta().validator(obj)
        else:
            LOG.debug("Interface '%s' does not have a validator() function!" %
                      interface)

        self.__handlers__[handler_type][obj.Meta.label] = orig_obj
dataset/ETHPy150Open datafolklabs/cement/cement/core/handler.py/HandlerManager.register/original