mirror of
https://github.com/django-components/django-components.git
synced 2025-07-14 12:14:59 +00:00
15 lines
479 B
Python
15 lines
479 B
Python
class AlreadyRegistered(Exception):
|
|
pass
|
|
|
|
class ComponentRegistry(object):
|
|
def __init__(self):
|
|
self._registry = {} # component name -> component_class mapping
|
|
|
|
def register(self, name=None, component=None):
|
|
if name in self._registry:
|
|
raise AlreadyRegistered('The component %s is already registered' % name)
|
|
|
|
self._registry[name] = component
|
|
|
|
# This variable represents the global component registry
|
|
registry = ComponentRegistry()
|