mirror of
https://github.com/evennia/evennia.git
synced 2026-03-21 15:26:30 +01:00
Minor additions to typeclass loading.
This commit is contained in:
parent
c513486b5a
commit
91f2a5930c
1 changed files with 5 additions and 15 deletions
|
|
@ -77,22 +77,12 @@ class TypeClass(object):
|
|||
# unless it's really a TypedObject.
|
||||
dbobj_cls = GA(dbobj, '__class__')
|
||||
dbobj_mro = GA(dbobj_cls, '__mro__')
|
||||
if not any('src.typeclasses.models.TypedObject'
|
||||
in str(mro) for mro in dbobj_mro):
|
||||
raise Exception("dbobj is not a TypedObject: %s: %s" % \
|
||||
(dbobj_cls, dbobj_mro))
|
||||
if not any('src.typeclasses.models.TypedObject' in str(mro) for mro in dbobj_mro):
|
||||
raise Exception("dbobj is not a TypedObject: %s: %s" % (dbobj_cls, dbobj_mro))
|
||||
|
||||
# store the needed things on the typeclass
|
||||
# store the reference to the database model instance
|
||||
SA(self, 'dbobj', dbobj)
|
||||
|
||||
# # sync the database object to this typeclass.
|
||||
# cls = GA(self, '__class__')
|
||||
# db_typeclass_path = "%s.%s" % (GA(cls, '__module__'),
|
||||
# GA(cls, '__name__'))
|
||||
# if not GA(dbobj, "db_typeclass_path") == db_typeclass_path:
|
||||
# SA(dbobj, "db_typeclass_path", db_typeclass_path)
|
||||
# GA(dbobj, "save")()
|
||||
|
||||
def __getattribute__(self, propname):
|
||||
"""
|
||||
Change the normal property access to
|
||||
|
|
@ -123,10 +113,10 @@ class TypeClass(object):
|
|||
except AttributeError:
|
||||
try:
|
||||
if propname == 'ndb':
|
||||
# get non-persistent data
|
||||
# get non-persistent data (getattr raises AttributeError)
|
||||
return getattr(GA(dbobj, 'ndb'), propname)
|
||||
else:
|
||||
return dbobj.get_attribute_raise(propname)
|
||||
return GA(dbobj,"get_attribute_raise")(propname)
|
||||
except AttributeError:
|
||||
string = "Object: '%s' not found on %s(%s), nor on its typeclass %s."
|
||||
raise AttributeError(string % (propname, dbobj,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue