def handle(self, event: object) -> None: """ Handle events coming from elements. """ if isinstance(event, UnlinkEvent): self._unlink_element(event.element) event = ElementDeleted(self, event.element) if self.event_manager and not self._block_events: self.event_manager.handle(event)
def handle(self, event: object) -> None: """Handle events coming from elements.""" if isinstance(event, UnlinkEvent): element = event.element assert isinstance(element.id, str) try: del self._elements[element.id] except KeyError: return event = ElementDeleted(self, event.element) if self.event_manager and not self._block_events: self.event_manager.handle(event)
def _undo_create_event(): try: del factory._elements[element.id] except KeyError: pass # Key was probably already removed in an unlink call self.event_manager.handle(ElementDeleted(factory, element))