Render components as views (#366) (thanks @dylanjcastillo)

This commit is contained in:
Dylan Castillo 2024-01-24 22:36:57 +01:00 committed by GitHub
parent b29e7fba80
commit 91b4accfeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 347 additions and 15 deletions

View file

@ -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):