code: def register(self, model, handler=None):
          
          from permission.handlers import PermissionHandler
          if model._meta.abstract:
              raise ImproperlyConfigured(
                      'The model %s is abstract, so it cannot be registered '
                      'with permission.' % model)
          if model in self._registry:
              raise KeyError("A permission handler class is already "
                              "registered for '%s'" % model)
          if handler is None:
              handler = settings.PERMISSION_DEFAULT_PERMISSION_HANDLER
          if isstr(handler):
              handler = import_string(handler)
          if not inspect.isclass(handler):
              raise AttributeError(
                      "`handler` attribute must be a class. "
                      "An instance was specified.")
          if not issubclass(handler, PermissionHandler):
              raise AttributeError(
                      "`handler` attribute must be a subclass of "
                      "`permission.handlers.PermissionHandler`")
  
          # Instantiate the handler to save in the registry
          instance = handler(model)
          self._registry[model] = instance
docs: Register a permission handler to the model
  
          Parameters
          ----------
          model : django model class
              A django model class
          handler : permission handler class, string, or None
              A permission handler class or a dotted path
  
          Raises
          ------
          ImproperlyConfigured
              Raise when the model is abstract model
          KeyError
              Raise when the model is already registered in registry
              The model cannot have more than one handler.