makes attributeproperties object-aware, part 2

This commit is contained in:
Tegiminis 2022-07-10 03:20:16 -07:00
parent da0e380fa5
commit 6fca198a70

View file

@ -218,7 +218,6 @@ class AttributeProperty:
""" """
value = self._default value = self._default
try: try:
<<<<<<< HEAD
value = self.at_get(getattr(instance, self.attrhandler_name).get( value = self.at_get(getattr(instance, self.attrhandler_name).get(
key=self._key, key=self._key,
default=self._default, default=self._default,
@ -226,17 +225,6 @@ class AttributeProperty:
strattr=self._strattr, strattr=self._strattr,
raise_exception=self._autocreate, raise_exception=self._autocreate,
), instance) ), instance)
=======
value = self.at_get(
getattr(instance, self.attrhandler_name).get(
key=self._key,
default=self._default,
category=self._category,
strattr=self._strattr,
raise_exception=self._autocreate,
)
)
>>>>>>> ce3992f999a164881462d8f878d71a47a8f946cc
except AttributeError: except AttributeError:
if self._autocreate: if self._autocreate:
# attribute didn't exist and autocreate is set # attribute didn't exist and autocreate is set
@ -253,7 +241,7 @@ class AttributeProperty:
( (
getattr(instance, self.attrhandler_name).add( getattr(instance, self.attrhandler_name).add(
self._key, self._key,
self.at_set(value), self.at_set(value, instance),
category=self._category, category=self._category,
lockstring=self._lockstring, lockstring=self._lockstring,
strattr=self._strattr, strattr=self._strattr,
@ -269,7 +257,7 @@ class AttributeProperty:
""" """
getattr(instance, self.attrhandler_name).remove(key=self._key, category=self._category) getattr(instance, self.attrhandler_name).remove(key=self._key, category=self._category)
def at_set(self, value): def at_set(self, value, obj):
""" """
The value to set is passed through the method. It can be used to customize/validate The value to set is passed through the method. It can be used to customize/validate
the input in a custom child class. the input in a custom child class.