diff --git a/src/commands/default/system.py b/src/commands/default/system.py index 6288b8b095..3bd453e032 100644 --- a/src/commands/default/system.py +++ b/src/commands/default/system.py @@ -213,6 +213,15 @@ def format_script_list(scripts): table.align = 'r' for script in scripts: nextrep = script.time_until_next_repeat() + print ([script.id, + (not hasattr(script, 'obj') or not script.obj) and "" or script.obj.key, + script.key, + (not hasattr(script, 'interval') or script.interval < 0) and "--" or "%ss" % script.interval, + not nextrep and "--" or "%ss" % nextrep, + (not hasattr(script, 'repeats') or not script.repeats) and "--" or "%i" % script.repeats, + script.persistent and "*" or "-", + script.typeclass_path.rsplit('.', 1)[-1], + script.desc]) table.add_row([script.id, (not hasattr(script, 'obj') or not script.obj) and "" or script.obj.key, script.key, diff --git a/src/objects/models.py b/src/objects/models.py index 887e7b5848..eca42c30c8 100644 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -143,6 +143,8 @@ class ObjectDB(TypedObject): _SA(self, "tags", TagHandler(self, category_prefix="object_")) _SA(self, "aliases", AliasHandler(self, category_prefix="object_")) _SA(self, "nicks", NickHandler(self, category_prefix="object_")) + # make sure to sync the contents cache when initializing + self.contents_update() # Wrapper properties to easily set database fields. These are # @property decorators that allows to access these fields using @@ -152,6 +154,7 @@ class ObjectDB(TypedObject): # value = self.attr and del self.attr respectively (where self # is the object in question). + #TODO - make player-handler # player property (wraps db_player) #@property def __player_get(self): @@ -187,25 +190,25 @@ class ObjectDB(TypedObject): # sessid property (wraps db_sessid) #@property - def __sessid_get(self): - """ - Getter. Allows for value = self.sessid. Since sessid - is directly related to self.player, we cannot have - a sessid without a player being connected (but the - opposite could be true). - """ - if not get_field_cache(self, "sessid"): - del_field_cache(self, "sessid") - return get_field_cache(self, "sessid") - #@sessid.setter - def __sessid_set(self, sessid): - "Setter. Allows for self.player = value" - set_field_cache(self, "sessid", sessid) - #@sessid.deleter - def __sessid_del(self): - "Deleter. Allows for del self.player" - del_field_cache(self, "sessid") - sessid = property(__sessid_get, __sessid_set, __sessid_del) + #def __sessid_get(self): + # """ + # Getter. Allows for value = self.sessid. Since sessid + # is directly related to self.player, we cannot have + # a sessid without a player being connected (but the + # opposite could be true). + # """ + # if not get_field_cache(self, "sessid"): + # del_field_cache(self, "sessid") + # return get_field_cache(self, "sessid") + ##@sessid.setter + #def __sessid_set(self, sessid): + # "Setter. Allows for self.player = value" + # set_field_cache(self, "sessid", sessid) + ##@sessid.deleter + #def __sessid_del(self): + # "Deleter. Allows for del self.player" + # del_field_cache(self, "sessid") + #sessid = property(__sessid_get, __sessid_set, __sessid_del) def _db_location_handler(self, loc, old_value=None): "This handles changes to the db_location field." diff --git a/src/scripts/models.py b/src/scripts/models.py index 8614a481fe..032695c2e6 100644 --- a/src/scripts/models.py +++ b/src/scripts/models.py @@ -110,7 +110,6 @@ class ScriptDB(TypedObject): _SA(self, "tags", TagHandler(self, category_prefix="script_")) _SA(self, "aliases", AliasHandler(self, category_prefix="script_")) - # Wrapper properties to easily set database fields. These are # @property decorators that allows to access these fields using # normal python operations (without having to remember to save() diff --git a/src/typeclasses/models.py b/src/typeclasses/models.py index 068795c524..0f23c9db62 100644 --- a/src/typeclasses/models.py +++ b/src/typeclasses/models.py @@ -232,10 +232,10 @@ class Attribute(SharedMemoryModel): # def __str__(self): - return smart_str("%s(%s)" % (self.key, self.id)) + return smart_str("%s(%s)" % (_GA(self, "db_key", _GA(self, "id")))) def __unicode__(self): - return u"%s(%s)" % (self.key, self.id) + return u"%s(%s)" % (_GA(self, "db_key", _GA(self, "id"))) def access(self, accessing_obj, access_type='read', default=False): """ @@ -739,10 +739,10 @@ class TypedObject(SharedMemoryModel): return other and hasattr(other, 'dbid') and self.dbid == other.dbid def __str__(self): - return smart_str("%s" % self.key) + return smart_str("%s" % _GA(self, "db_key")) def __unicode__(self): - return u"%s" % self.key + return u"%s" % _GA(self, "db_key") def __getattribute__(self, propname): """ diff --git a/src/utils/idmapper/base.py b/src/utils/idmapper/base.py index 558d5f3d81..d0d1b3bb3c 100755 --- a/src/utils/idmapper/base.py +++ b/src/utils/idmapper/base.py @@ -98,7 +98,7 @@ class SharedMemoryModelBase(ModelBase): "Wrapper for setting database field" if hasattr(value, "dbobj"): value = _GA(value, "dbobj") - elif fname.isdigit() or fname.startswith("#"): + elif isinstance(value, basestring) and (value.isdigit() or value.startswith("#")): # we also allow setting using dbrefs, if so we try to load the matching object. # (we assume the object is of the same type as the class holding the field, if # not a custom handler must be used for that field)