Use get_component_slot

This commit is contained in:
ChrisLR 2024-02-24 11:12:49 -05:00
parent 8bda7c10f7
commit 0729de1b91
2 changed files with 6 additions and 6 deletions

View file

@ -29,7 +29,7 @@ class DBField(AttributeProperty):
owner (Component): The component classF on which this is set owner (Component): The component classF on which this is set
name (str): The name that was used to set the DBField. name (str): The name that was used to set the DBField.
""" """
self._key = f"{owner.slot or owner.name}::{name}" self._key = f"{owner.get_component_slot()}::{name}"
owner.add_field(name, self) owner.add_field(name, self)
def at_added(self, component): def at_added(self, component):
@ -69,7 +69,7 @@ class NDBField(NAttributeProperty):
owner (Component): The component class on which this is set owner (Component): The component class on which this is set
name (str): The name that was used to set the DBField. name (str): The name that was used to set the DBField.
""" """
self._key = f"{owner.slot or owner.name}::{name}" self._key = f"{owner.get_component_slot()}::{name}"
owner.add_field(name, self) owner.add_field(name, self)
def at_added(self, component): def at_added(self, component):
@ -113,7 +113,7 @@ class TagField:
Called when TagField is first assigned to the class. Called when TagField is first assigned to the class.
It is called with the component class and the name of the field. It is called with the component class and the name of the field.
""" """
self._category_key = f"{owner.slot or owner.name}::{name}" self._category_key = f"{owner.get_component_slot()}::{name}"
owner.add_field(name, self) owner.add_field(name, self)
def __get__(self, instance, owner): def __get__(self, instance, owner):

View file

@ -34,7 +34,7 @@ class ComponentProperty:
if not self.component_class: if not self.component_class:
component_class = get_component_class(self.name) component_class = get_component_class(self.name)
self.component_class = component_class self.component_class = component_class
self.slot_name = component_class.slot or component_class.name self.slot_name = component_class.get_component_slot()
component = instance.components.get(self.slot_name) component = instance.components.get(self.slot_name)
return component return component
@ -107,7 +107,7 @@ class ComponentHandler:
""" """
name = component.name name = component.name
slot_name = component.slot or name slot_name = component.get_component_slot()
if not self.has(slot_name): if not self.has(slot_name):
message = ( message = (
f"Cannot remove {name} from {self.host.name} as it is not registered." f"Cannot remove {name} from {self.host.name} as it is not registered."
@ -181,7 +181,7 @@ class ComponentHandler:
""" """
Sets the loaded component in this instance. Sets the loaded component in this instance.
""" """
slot_name = component.slot or component.name slot_name = component.get_component_slot()
self._loaded_components[slot_name] = component self._loaded_components[slot_name] = component
self.host.signals.add_object_listeners_and_responders(component) self.host.signals.add_object_listeners_and_responders(component)