diff --git a/src/commands/default/system.py b/src/commands/default/system.py index a4ebe5d10b..0be341124d 100644 --- a/src/commands/default/system.py +++ b/src/commands/default/system.py @@ -210,7 +210,7 @@ def format_script_list(scripts): class CmdScripts(MuxCommand): """ - Operate on scripts. + Operate and list global scripts, list all scrips. Usage: @scripts[/switches] [] diff --git a/src/typeclasses/models.py b/src/typeclasses/models.py index d3eb509ec7..0f3f32a766 100644 --- a/src/typeclasses/models.py +++ b/src/typeclasses/models.py @@ -919,6 +919,27 @@ class TypedObject(SharedMemoryModel): raise Exception("dbref cannot be deleted!") dbref = property(__dbref_get, __dbref_set, __dbref_del) + #@property + _hashid_cache = None + def __hashid_get(self): + """ + Returns a per-class unique that combines the object's + class name with its idnum. This makes this id unique also + between different typeclassed entities such as scripts and + objects (which may still have the same id). + Primarily used by Attribute caching system. + """ + hashid = _GA(self, "_hashid_cache") + if not hashid: + hashid = "%s<#%s>" % (_GA(self, "__class__"), _GA(self, "dbid")) + _SA(self, "_hashid_cache", hashid) + return hashid + def __hashid_set(self): + raise Exception("hashid cannot be set!") + def __hashid_del(self): + raise Exception("hashid cannot be deleted!") + hashid = property(__hashid_get, __hashid_set, __hashid_del) + # typeclass property #@property def __typeclass_get(self): @@ -1227,11 +1248,11 @@ class TypedObject(SharedMemoryModel): attribute_name: (str) The attribute's name. """ - if attribute_name not in _ATTRIBUTE_CACHE[self]: + if attribute_name not in _ATTRIBUTE_CACHE[_GA(self, "hashid")]: attrib_obj = _GA(self, "_attribute_class").objects.filter(db_obj=self).filter( db_key__iexact=attribute_name) if attrib_obj: - _ATTRIBUTE_CACHE[self][attribute_name] = attrib_obj[0] + _ATTRIBUTE_CACHE[_GA(self, "hashid")][attribute_name] = attrib_obj[0] else: return False return True @@ -1245,7 +1266,7 @@ class TypedObject(SharedMemoryModel): new_value: (python obj) The value to set the attribute to. If this is not a str, the object will be stored as a pickle. """ - attrib_obj = _ATTRIBUTE_CACHE[self].get("attribute_name") + attrib_obj = _ATTRIBUTE_CACHE[_GA(self, "hashid")].get("attribute_name") if not attrib_obj: attrclass = _GA(self, "_attribute_class") # check if attribute already exists. @@ -1259,7 +1280,7 @@ class TypedObject(SharedMemoryModel): attrib_obj = attrclass(db_key=attribute_name, db_obj=self) # re-set an old attribute value attrib_obj.value = new_value - _ATTRIBUTE_CACHE[self][attribute_name] = attrib_obj + _ATTRIBUTE_CACHE[_GA(self, "hashid")][attribute_name] = attrib_obj def get_attribute(self, attribute_name, default=None): """ @@ -1270,14 +1291,14 @@ class TypedObject(SharedMemoryModel): attribute_name: (str) The attribute's name. default: What to return if no attribute is found """ - attrib_obj = _ATTRIBUTE_CACHE[self].get(attribute_name) + attrib_obj = _ATTRIBUTE_CACHE[_GA(self, "hashid")].get(attribute_name) if not attrib_obj: attrib_obj = _GA(self, "_attribute_class").objects.filter( db_obj=self).filter(db_key__iexact=attribute_name) if not attrib_obj: return default - _ATTRIBUTE_CACHE[self][attribute_name] = attrib_obj[0] #query is first evaluated here - return _ATTRIBUTE_CACHE[self][attribute_name].value + _ATTRIBUTE_CACHE[_GA(self, "hashid")][attribute_name] = attrib_obj[0] #query is first evaluated here + return _ATTRIBUTE_CACHE[_GA(self, "hashid")][attribute_name].value return attrib_obj.value def get_attribute_raise(self, attribute_name): @@ -1287,14 +1308,14 @@ class TypedObject(SharedMemoryModel): attribute_name: (str) The attribute's name. """ - attrib_obj = _ATTRIBUTE_CACHE[self].get(attribute_name) + attrib_obj = _ATTRIBUTE_CACHE[_GA(self, "hashid")].get(attribute_name) if not attrib_obj: attrib_obj = _GA(self, "_attribute_class").objects.filter( db_obj=self).filter(db_key__iexact=attribute_name) if not attrib_obj: raise AttributeError - _ATTRIBUTE_CACHE[self][attribute_name] = attrib_obj[0] #query is first evaluated here - return _ATTRIBUTE_CACHE[self][attribute_name].value + _ATTRIBUTE_CACHE[_GA(self, "hashid")][attribute_name] = attrib_obj[0] #query is first evaluated here + return _ATTRIBUTE_CACHE[_GA(self, "hashid")][attribute_name].value return attrib_obj.value def del_attribute(self, attribute_name): @@ -1303,9 +1324,9 @@ class TypedObject(SharedMemoryModel): attribute_name: (str) The attribute's name. """ - attr_obj = _ATTRIBUTE_CACHE[self].get(attribute_name) + attr_obj = _ATTRIBUTE_CACHE[_GA(self, "hashid")].get(attribute_name) if attr_obj: - del _ATTRIBUTE_CACHE[self][attribute_name] + del _ATTRIBUTE_CACHE[_GA(self, "hashid")][attribute_name] attr_obj.delete() else: try: @@ -1321,9 +1342,9 @@ class TypedObject(SharedMemoryModel): attribute_name: (str) The attribute's name. """ - attr_obj = _ATTRIBUTE_CACHE[self].get(attribute_name) + attr_obj = _ATTRIBUTE_CACHE[_GA(self, "hashid")].get(attribute_name) if attr_obj: - del _ATTRIBUTE_CACHE[self][attribute_name] + del _ATTRIBUTE_CACHE[_GA(self, "hashid")][attribute_name] attr_obj.delete() else: try: diff --git a/src/utils/dummyrunner_actions.py b/src/utils/dummyrunner_actions.py index 7bea56bc82..854d8359b0 100644 --- a/src/utils/dummyrunner_actions.py +++ b/src/utils/dummyrunner_actions.py @@ -144,25 +144,25 @@ def c_moves(client): # # heavy builder definition -#ACTIONS = ( c_login, -# c_logout, -# (0.2, c_looks), -# (0.1, c_examines), -# (0.2, c_help), -# (0.1, c_digs), -# (0.1, c_creates_obj), -# #(0.1, c_creates_button), -# (0.2, c_moves)) -# "normal builder" definition ACTIONS = ( c_login, c_logout, - (0.5, c_looks), - (0.08, c_examines), - (0.1, c_help), - (0.01, c_digs), - (0.01, c_creates_obj), + (0.2, c_looks), + (0.1, c_examines), + (0.2, c_help), + (0.1, c_digs), + (0.1, c_creates_obj), #(0.1, c_creates_button), - (0.3, c_moves)) + (0.2, c_moves)) +# "normal builder" definition +#ACTIONS = ( c_login, +# c_logout, +# (0.5, c_looks), +# (0.08, c_examines), +# (0.1, c_help), +# (0.01, c_digs), +# (0.01, c_creates_obj), +# #(0.1, c_creates_button), +# (0.3, c_moves)) # "normal player" definition #ACTIONS = ( c_login, # c_logout,