Fixed updates of the contentmanager. Not all command tests run yet.
This commit is contained in:
parent
6bc16e46cc
commit
73a5800fbf
5 changed files with 36 additions and 25 deletions
|
|
@ -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 "<Global>" 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 "<Global>" or script.obj.key,
|
||||
script.key,
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue