code: def _register(self, cls):
          
          if not inspect.isclass(cls):
              raise ValueError('Only classes may be registered.')
          elif not issubclass(cls, self._registerable_class):
              raise ValueError('Only %s classes or subclasses may be registered.'
                               % self._registerable_class.__name__)
  
          if cls not in self._registry:
              cls._registered_with = self
              self._registry[cls] = cls()
  
          return self._registry[cls]
docs: Registers the given class.
  
          If the specified class is already registered then it is ignored.