Removed .typeclass and .dbobj references in codebase.

This commit is contained in:
Griatch 2015-01-02 20:48:34 +01:00
parent 1130dc5757
commit 70da53569d
23 changed files with 60 additions and 127 deletions

View file

@ -119,7 +119,6 @@ class ObjectDBAdmin(admin.ModelAdmin):
obj.save()
if not change:
# adding a new object
obj = obj.typeclass
obj.basetype_setup()
obj.basetype_posthook_setup()
obj.at_object_creation()

View file

@ -156,8 +156,6 @@ class ObjectDBManager(TypedObjectManager):
if isinstance(property_name, basestring):
if not property_name.startswith('db_'):
property_name = "db_%s" % property_name
if hasattr(property_value, 'dbobj'):
property_value = property_value.dbobj
querykwargs = {property_name:property_value}
cand_restriction = candidates != None and Q(pk__in=[_GA(obj, "id") for obj in make_iter(candidates) if obj]) or Q()
type_restriction = typeclasses and Q(db_typeclass_path__in=make_iter(typeclasses)) or Q()
@ -299,7 +297,7 @@ class ObjectDBManager(TypedObjectManager):
if candidates:
# Convenience check to make sure candidates are really dbobjs
candidates = [cand.dbobj for cand in make_iter(candidates) if cand]
candidates = [cand for cand in make_iter(candidates) if cand]
if typeclass:
candidates = [cand for cand in candidates
if _GA(cand, "db_typeclass_path") in typeclass]
@ -309,7 +307,7 @@ class ObjectDBManager(TypedObjectManager):
# Easiest case - dbref matching (always exact)
dbref_match = self.dbref_search(dbref)
if dbref_match:
if not candidates or dbref_match.dbobj in candidates:
if not candidates or dbref_match in candidates:
return [dbref_match]
else:
return []
@ -402,7 +400,7 @@ class ObjectDBManager(TypedObjectManager):
# copy over all scripts, if any
for script in original_object.scripts.all():
ScriptDB.objects.copy_script(script, new_obj=new_object.dbobj)
ScriptDB.objects.copy_script(script, new_obj=new_object)
return new_object

View file

@ -115,10 +115,6 @@ class DefaultObject(ObjectDB):
aliases (list of strings) - aliases to the object. Will be saved to
database as AliasDB entries but returned as strings.
dbref (int, read-only) - unique #id-number. Also "id" can be used.
dbobj (Object, read-only) - link to database model. dbobj.typeclass
points back to this class
typeclass (Object, read-only) - this links back to this class as an
identified only. Use self.swap_typeclass() to switch.
date_created (string) - time stamp of object creation
permissions (list of strings) - list of permission strings
@ -886,6 +882,16 @@ class DefaultObject(ObjectDB):
if cdict.get("location"):
cdict["location"].at_object_receive(self, None)
self.at_after_move(None)
if cdict.get("attributes"):
# this should be a dict of attrname:value
keys, values = cdict["attributes"].keys(), cdict["attributes"].values()
self.attributes.batch_add(keys, values)
if cdict.get("nattributes"):
# this should be a dict of nattrname:value
for key, value in cdict["nattributes"].items():
self.nattributes.add(key, value)
del self._createdict
self.basetype_posthook_setup()
@ -1437,8 +1443,8 @@ class DefaultExit(DefaultObject):
"get:false()"])) # noone can pick up the exit
# an exit should have a destination (this is replaced at creation time)
if self.dbobj.location:
self.destination = self.dbobj.location
if self.location:
self.destination = self.location
def at_cmdset_get(self, **kwargs):
"""
@ -1452,7 +1458,7 @@ class DefaultExit(DefaultObject):
if "force_init" in kwargs or not self.cmdset.has_cmdset("_exitset", must_be_default=True):
# we are resetting, or no exit-cmdset was set. Create one dynamically.
self.cmdset.add_default(self.create_exit_cmdset(self.dbobj), permanent=False)
self.cmdset.add_default(self.create_exit_cmdset(self), permanent=False)
# this and other hooks are what usually can be modified safely.