Fix issue with init_evennia_properties.
This commit is contained in:
parent
ef7280f55a
commit
d5c916ecc3
2 changed files with 14 additions and 3 deletions
|
|
@ -241,11 +241,17 @@ class TestObjectPropertiesClass(DefaultObject):
|
||||||
testalias = AliasProperty()
|
testalias = AliasProperty()
|
||||||
testperm = PermissionProperty()
|
testperm = PermissionProperty()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def base_property(self):
|
||||||
|
self.property_initialized = True
|
||||||
|
|
||||||
|
|
||||||
class TestProperties(EvenniaTestCase):
|
class TestProperties(EvenniaTestCase):
|
||||||
"""
|
"""
|
||||||
Test Properties.
|
Test Properties.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.obj = create.create_object(TestObjectPropertiesClass, key="testobj")
|
self.obj = create.create_object(TestObjectPropertiesClass, key="testobj")
|
||||||
|
|
||||||
|
|
@ -280,3 +286,7 @@ class TestProperties(EvenniaTestCase):
|
||||||
|
|
||||||
self.assertTrue(obj.aliases.has("testalias"))
|
self.assertTrue(obj.aliases.has("testalias"))
|
||||||
self.assertTrue(obj.permissions.has("testperm"))
|
self.assertTrue(obj.permissions.has("testperm"))
|
||||||
|
|
||||||
|
# Verify that regular properties do not get fetched in init_evennia_properties,
|
||||||
|
# only Attribute or TagProperties.
|
||||||
|
self.assertFalse(hasattr(obj, "property_initialized"))
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,12 @@ from django.utils.text import slugify
|
||||||
from evennia.typeclasses.attributes import (
|
from evennia.typeclasses.attributes import (
|
||||||
Attribute,
|
Attribute,
|
||||||
AttributeHandler,
|
AttributeHandler,
|
||||||
|
AttributeProperty,
|
||||||
ModelAttributeBackend,
|
ModelAttributeBackend,
|
||||||
InMemoryAttributeBackend,
|
InMemoryAttributeBackend,
|
||||||
)
|
)
|
||||||
from evennia.typeclasses.attributes import DbHolder
|
from evennia.typeclasses.attributes import DbHolder
|
||||||
from evennia.typeclasses.tags import Tag, TagHandler, AliasHandler, PermissionHandler
|
from evennia.typeclasses.tags import Tag, TagHandler, AliasHandler, PermissionHandler, TagProperty
|
||||||
|
|
||||||
from evennia.utils.idmapper.models import SharedMemoryModel, SharedMemoryModelBase
|
from evennia.utils.idmapper.models import SharedMemoryModel, SharedMemoryModelBase
|
||||||
from evennia.server.signals import SIGNAL_TYPED_OBJECT_POST_RENAME
|
from evennia.server.signals import SIGNAL_TYPED_OBJECT_POST_RENAME
|
||||||
|
|
@ -331,7 +332,7 @@ class TypedObject(SharedMemoryModel):
|
||||||
by fetching them once.
|
by fetching them once.
|
||||||
"""
|
"""
|
||||||
for propkey, prop in self.__class__.__dict__.items():
|
for propkey, prop in self.__class__.__dict__.items():
|
||||||
if hasattr(prop, "__set_name__"):
|
if isinstance(prop, (AttributeProperty, TagProperty)):
|
||||||
try:
|
try:
|
||||||
getattr(self, propkey)
|
getattr(self, propkey)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue