Make manually setting a valid class that is not a typeclass gracefully degrade with log error. Resolves #999.
This commit is contained in:
parent
bbc2f255fc
commit
61a0e49f66
1 changed files with 9 additions and 2 deletions
|
|
@ -243,7 +243,7 @@ class TypedObject(SharedMemoryModel):
|
||||||
log_trace()
|
log_trace()
|
||||||
self.__class__ = self._meta.proxy_for_model or self.__class__
|
self.__class__ = self._meta.proxy_for_model or self.__class__
|
||||||
finally:
|
finally:
|
||||||
self.db_typclass_path = typeclass_path
|
self.db_typeclass_path = typeclass_path
|
||||||
elif self.db_typeclass_path:
|
elif self.db_typeclass_path:
|
||||||
try:
|
try:
|
||||||
self.__class__ = class_from_module(self.db_typeclass_path)
|
self.__class__ = class_from_module(self.db_typeclass_path)
|
||||||
|
|
@ -257,7 +257,14 @@ class TypedObject(SharedMemoryModel):
|
||||||
else:
|
else:
|
||||||
self.db_typeclass_path = "%s.%s" % (self.__module__, self.__class__.__name__)
|
self.db_typeclass_path = "%s.%s" % (self.__module__, self.__class__.__name__)
|
||||||
# important to put this at the end since _meta is based on the set __class__
|
# important to put this at the end since _meta is based on the set __class__
|
||||||
|
try:
|
||||||
self.__dbclass__ = self._meta.proxy_for_model or self.__class__
|
self.__dbclass__ = self._meta.proxy_for_model or self.__class__
|
||||||
|
except AttributeError:
|
||||||
|
err_class = repr(self.__class__)
|
||||||
|
self.__class__ = class_from_module("evennia.objects.objects.DefaultObject")
|
||||||
|
self.__dbclass__ = class_from_module("evennia.objects.models.ObjectDB")
|
||||||
|
self.db_typeclass_path = "evennia.objects.objects.DefaultObject"
|
||||||
|
log_trace("Critical: Class %s of %s is not a valid typeclass!\nTemporarily falling back to %s." % (err_class, self, self.__class__))
|
||||||
|
|
||||||
# initialize all handlers in a lazy fashion
|
# initialize all handlers in a lazy fashion
|
||||||
@lazy_property
|
@lazy_property
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue