Пример #1
0
 def bind(self, element: Element) -> None:
     """
     Bind an already created element to the element factory.
     The element may not be bound to another factory already.
     """
     if hasattr(element, "_model") and element._model:
         raise AttributeError("element is already bound")
     if not isinstance(element.id, str):
         raise AttributeError(
             f"Element should contain a string id (found: {element.id}")
     if self._elements.get(element.id):
         raise AttributeError("an element already exists with the same id")
     element._model = self
     self._elements[element.id] = element
Пример #2
0
 def unlink(self):
     self.is_unlinked = True
     Element.unlink()
Пример #3
0
 def unlink(self):
     self.is_unlinked = True
     Element.unlink(self)