From cfd2f111f164a1cc4a653d08cb80b780707cd2bd Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 11 May 2014 19:41:37 +0200 Subject: [PATCH] Updating to make unittests work --- src/commands/default/building.py | 2 +- src/objects/manager.py | 2 +- src/typeclasses/models.py | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/commands/default/building.py b/src/commands/default/building.py index 7c470a1fc4..6dc15be231 100644 --- a/src/commands/default/building.py +++ b/src/commands/default/building.py @@ -325,7 +325,7 @@ class CmdCpAttr(ObjManipCommand): to_obj.attributes.add(to_attr, srcvalue) if ("move" in self.switches and not (from_obj == to_obj and from_attr == to_attr)): - from_obj.del_attribute(from_attr) + from_obj.attributes.remove(from_attr) string += "\nMoved %s.%s -> %s.%s." % (from_obj.name, from_attr, to_obj_name, to_attr) diff --git a/src/objects/manager.py b/src/objects/manager.py index 9aaa474861..4a0a0aad41 100644 --- a/src/objects/manager.py +++ b/src/objects/manager.py @@ -389,7 +389,7 @@ class ObjectManager(TypedObjectManager): return None # copy over all attributes from old to new. - for attr in original_object.get_all_attributes(): + for attr in original_object.attributes.all(): new_object.attributes.add(attr.key, attr.value) # copy over all cmdsets, if any diff --git a/src/typeclasses/models.py b/src/typeclasses/models.py index 2d36e16609..50bb377ff3 100644 --- a/src/typeclasses/models.py +++ b/src/typeclasses/models.py @@ -128,11 +128,20 @@ class Attribute(WeakSharedMemoryModel): key = property(lambda self: self.db_key) strvalue = property(lambda self: self.db_strvalue) category = property(lambda self: self.db_category) - lock_storage = property(lambda self: self.db_lockstorage) model = property(lambda self: self.db_model) attrtype = property(lambda self: self.db_attrtype) date_created = property(lambda self: self.db_date_created) + def __lock_storage_get(self): + return self.db_lock_storage + def __lock_storage_set(self, value): + self.db_lock_storage = value + self.save(update_fields=["db_lock_storage"]) + def __lock_storage_del(self): + self.db_lock_storage = "" + self.save(update_fields=["db_lock_storage"]) + lock_storage = property(__lock_storage_get, __lock_storage_set, __lock_storage_del) + # 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()