diff --git a/src/commands/cmdhandler.py b/src/commands/cmdhandler.py index de21c3c1cc..c24ca3c69b 100644 --- a/src/commands/cmdhandler.py +++ b/src/commands/cmdhandler.py @@ -130,7 +130,7 @@ def get_and_merge_cmdsets(caller, session, player, obj, if location and not obj_cmdset.no_objs: # Gather all cmdsets stored on objects in the room and # also in the caller's inventory and the location itself - local_objlist = yield (location.contents_get(exclude=obj.dbobj) + + local_objlist = yield (location.contents_get(exclude=obj) + obj.contents + [location]) for lobj in local_objlist: @@ -283,11 +283,11 @@ def cmdhandler(called_by, raw_string, _testing=False, callertype="session", sess session = called_by player = session.player if player: - obj = yield _GA(player.dbobj, "get_puppet")(session.sessid) + obj = yield player.get_puppet(session.sessid) elif callertype == "player": player = called_by if sessid: - obj = yield _GA(player.dbobj, "get_puppet")(sessid) + obj = yield player.get_puppet(sessid) elif callertype == "object": obj = called_by else: diff --git a/src/objects/models.py b/src/objects/models.py index fef5912cc8..d1f7135d10 100644 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -252,14 +252,14 @@ class ObjectDB(TypedObject): raise RuntimeError elif loc == None: raise RuntimeWarning - return is_loc_loop(_GA(_GA(loc, "dbobj"), "db_location"), depth + 1) + return is_loc_loop(loc.db_location, depth + 1) try: is_loc_loop(location) except RuntimeWarning: pass # actually set the field - _SA(_GA(self, "dbobj"), "db_location", _GA(location, "dbobj") if location else location) - _GA(_GA(self, "dbobj"), "save")(update_fields=["db_location"]) + self.db_location = location + self.save(update_fields=["db_location"]) except RuntimeError: errmsg = "Error: %s.location = %s creates a location loop." % (self.key, location) logger.log_errmsg(errmsg) @@ -271,8 +271,8 @@ class ObjectDB(TypedObject): def __location_del(self): "Cleanly delete the location reference" - _SA(_GA(self, "dbobj"), "db_location", None) - _GA(_GA(self, "dbobj"), "save")(upate_fields=["db_location"]) + self.db_location = None + self.save(update_fields=["db_location"]) location = property(__location_get, __location_set, __location_del) class Meta: @@ -323,8 +323,7 @@ class ObjectDB(TypedObject): exclude is one or more objects to not return """ if exclude: - exclude = [obj.dbobj for obj in make_iter(exclude)] - return ObjectDB.objects.get_contents(self, excludeobj=exclude) + return ObjectDB.objects.get_contents(self, excludeobj=make_iter(exclude)) return ObjectDB.objects.get_contents(self) contents = property(contents_get) @@ -423,7 +422,7 @@ class ObjectDB(TypedObject): # location(s) were given candidates = [] for obj in make_iter(location): - candidates.extend([o.dbobj for o in obj.contents]) + candidates.extend(obj.contents) else: # local search. Candidates are self.contents, self.location # and self.location.contents @@ -434,8 +433,6 @@ class ObjectDB(TypedObject): else: # normally we are included in location.contents candidates.append(self) - # db manager expects database objects - candidates = [obj.dbobj for obj in candidates] results = ObjectDB.objects.object_search(searchdata, attribute_name=attribute_name, diff --git a/src/objects/objects.py b/src/objects/objects.py index 249e80184e..6c62c0a29e 100644 --- a/src/objects/objects.py +++ b/src/objects/objects.py @@ -268,7 +268,7 @@ class Object(ObjectDB): if searchdata.lower() in ("me", "self",): return self - return self.dbobj.search(searchdata, + return super(Object, self).search(searchdata, global_search=global_search, use_nicks=use_nicks, typeclass=typeclass, @@ -305,7 +305,7 @@ class Object(ObjectDB): # searchdata is a string; wrap some common self-references if searchdata.lower() in ("me", "self",): return self.player - return self.dbobj.search_player(searchdata, quiet=quiet) + return super(Object, self).search_player(searchdata, quiet=quiet) def execute_cmd(self, raw_string, sessid=None, **kwargs): """ @@ -333,7 +333,7 @@ class Object(ObjectDB): useful for coders intending to implement some sort of nested command structure. """ - return self.dbobj.execute_cmd(raw_string, sessid=sessid, **kwargs) + return super(Object, self).execute_cmd(raw_string, sessid=sessid, **kwargs) def msg(self, text=None, from_obj=None, sessid=None, **kwargs): """ @@ -347,7 +347,7 @@ class Object(ObjectDB): default to self.sessid or from_obj.sessid. """ - self.dbobj.msg(text=text, from_obj=from_obj, sessid=sessid, **kwargs) + super(Object, self).msg(text=text, from_obj=from_obj, sessid=sessid, **kwargs) def msg_contents(self, text=None, exclude=None, from_obj=None, **kwargs): """ @@ -356,7 +356,7 @@ class Object(ObjectDB): exclude is a list of objects not to send to. See self.msg() for more info. """ - self.dbobj.msg_contents(text, exclude=exclude, + super(Object, self).msg_contents(text, exclude=exclude, from_obj=from_obj, **kwargs) def move_to(self, destination, quiet=False, @@ -387,7 +387,7 @@ class Object(ObjectDB): emit_to_obj. """ - return self.dbobj.move_to(destination, quiet=quiet, + return super(Object, self).move_to(destination, quiet=quiet, emit_to_obj=emit_to_obj, use_destination=use_destination) @@ -402,7 +402,7 @@ class Object(ObjectDB): _copy by default. Returns: Object (copy of this one) """ - return self.dbobj.copy(new_key=new_key) + return super(Object, self).copy(new_key=new_key) def delete(self): """ @@ -415,7 +415,7 @@ class Object(ObjectDB): were errors during deletion or deletion otherwise failed. """ - return self.dbobj.delete() + return super(Object, self).delete() # methods inherited from the typeclass system @@ -434,7 +434,7 @@ class Object(ObjectDB): Returns: Boolean """ - return self.dbobj.is_typeclass(typeclass, exact=exact) + return super(Object, self).is_typeclass(typeclass, exact=exact) def swap_typeclass(self, new_typeclass, clean_attributes=False, no_default=True): """ @@ -470,7 +470,7 @@ class Object(ObjectDB): """ - return self.dbobj.swap_typeclass(new_typeclass, + return super(Object, self).swap_typeclass(new_typeclass, clean_attributes=clean_attributes, no_default=no_default) def access(self, accessing_obj, access_type='read', default=False, **kwargs): @@ -483,7 +483,7 @@ class Object(ObjectDB): default (bool) - what to return if no lock of access_type was found **kwargs - passed to at_access hook along with result,accessing_obj and access_type """ - result = self.dbobj.access(accessing_obj, access_type=access_type, default=default) + result = super(Object, self).access(accessing_obj, access_type=access_type, default=default) self.at_access(result, accessing_obj, access_type, **kwargs) return result @@ -504,7 +504,7 @@ class Object(ObjectDB): permission on the object. (example: 'Builders') """ - return self.dbobj.check_permstring(permstring) + return super(Object, self).check_permstring(permstring) def __eq__(self, other): """ diff --git a/src/players/player.py b/src/players/player.py index 6a6198e31d..7cba8e61c9 100644 --- a/src/players/player.py +++ b/src/players/player.py @@ -124,7 +124,7 @@ class Player(PlayerDB): handles the sessid). kwargs - extra data to send through protocol """ - self.msg(text=text, from_obj=from_obj, sessid=sessid, **kwargs) + super(Player, self).msg(text=text, from_obj=from_obj, sessid=sessid, **kwargs) def swap_character(self, new_character, delete_old_character=False): """ @@ -135,7 +135,7 @@ class Player(PlayerDB): Returns: True/False depending on if swap suceeded or not. """ - return self.swap_character(new_character, delete_old_character=delete_old_character) + return super(Player, self).swap_character(new_character, delete_old_character=delete_old_character) def execute_cmd(self, raw_string, sessid=None, **kwargs): """ @@ -163,7 +163,7 @@ class Player(PlayerDB): be useful for coders intending to implement some sort of nested command structure. """ - return self.execute_cmd(raw_string, sessid=sessid, **kwargs) + return super(Player, self).execute_cmd(raw_string, sessid=sessid, **kwargs) def search(self, searchdata, return_puppet=False, **kwargs): """ @@ -183,7 +183,7 @@ class Player(PlayerDB): # handle wrapping of common terms if searchdata.lower() in ("me", "*me", "self", "*self",): return self - return self.search(searchdata, return_puppet=return_puppet, **kwargs) + return super(Player, self).search(searchdata, return_puppet=return_puppet, **kwargs) def is_typeclass(self, typeclass, exact=False): """ @@ -200,7 +200,7 @@ class Player(PlayerDB): Returns: Boolean """ - return self.is_typeclass(typeclass, exact=exact) + return super(Player, self).is_typeclass(typeclass, exact=exact) def swap_typeclass(self, new_typeclass, clean_attributes=False, no_default=True): """ @@ -235,7 +235,7 @@ class Player(PlayerDB): boolean True/False depending on if the swap worked or not. """ - self.swap_typeclass(new_typeclass, + super(Player, self).swap_typeclass(new_typeclass, clean_attributes=clean_attributes, no_default=no_default) def access(self, accessing_obj, access_type='read', default=False, **kwargs): @@ -248,7 +248,7 @@ class Player(PlayerDB): default (bool) - what to return if no lock of access_type was found **kwargs - passed to the at_access hook along with the result. """ - result = self.access(accessing_obj, access_type=access_type, default=default) + result = super(Player, self).access(accessing_obj, access_type=access_type, default=default) self.at_access(result, accessing_obj, access_type, **kwargs) return result @@ -261,7 +261,7 @@ class Player(PlayerDB): on the object. (example: 'Builders') Note that this method does -not- call the at_access hook. """ - return self.check_permstring(permstring) + return super(Player, self).check_permstring(permstring) ## player hooks diff --git a/src/scripts/manager.py b/src/scripts/manager.py index 6c82077d4d..b2509eb1f0 100644 --- a/src/scripts/manager.py +++ b/src/scripts/manager.py @@ -44,7 +44,6 @@ class ScriptDBManager(TypedObjectManager): """ if not obj: return [] - obj = obj.dbobj player = _GA(_GA(obj, "__class__"), "__name__") == "PlayerDB" if key: dbref = self.dbref(key) @@ -161,7 +160,7 @@ class ScriptDBManager(TypedObjectManager): # turn off the activity flag for all remaining scripts scripts = self.get_all_scripts() for script in scripts: - script.dbobj.is_active = False + script.is_active = False elif not scripts: # normal operation @@ -180,7 +179,7 @@ class ScriptDBManager(TypedObjectManager): #print "scripts to validate: [%s]" % (", ".join(script.key for script in scripts)) for script in scripts: - #print "validating %s (%i) (init_mode=%s)" % (script.key, id(script.dbobj), init_mode) + #print "validating %s (%i) (init_mode=%s)" % (script.key, id(script), init_mode) if script.is_valid(): nr_started += script.start(force_restart=init_mode) #print "back from start. nr_started=", nr_started @@ -212,7 +211,7 @@ class ScriptDBManager(TypedObjectManager): return [dbref_match] # not a dbref; normal search - obj_restriction = obj and Q(db_obj=obj.dbobj) or Q() + obj_restriction = obj and Q(db_obj=obj) or Q() timed_restriction = only_timed and Q(interval__gt=0) or Q() scripts = self.filter(timed_restriction & obj_restriction & Q(db_key__iexact=ostring)) return scripts