mirror of
https://github.com/django-components/django-components.git
synced 2025-09-16 02:45:00 +00:00
Render components as views (#366) (thanks @dylanjcastillo)
This commit is contained in:
parent
b29e7fba80
commit
91b4accfeb
10 changed files with 347 additions and 15 deletions
|
@ -11,11 +11,14 @@ class ComponentRegistry(object):
|
|||
self._registry = {} # component name -> component_class mapping
|
||||
|
||||
def register(self, name=None, component=None):
|
||||
if name in self._registry:
|
||||
existing_component = self._registry.get(name)
|
||||
if (
|
||||
existing_component
|
||||
and existing_component.class_hash != component.class_hash
|
||||
):
|
||||
raise AlreadyRegistered(
|
||||
'The component "%s" is already registered' % name
|
||||
'The component "%s" has already been registered' % name
|
||||
)
|
||||
|
||||
self._registry[name] = component
|
||||
|
||||
def unregister(self, name):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue