From 37886adea12c3aae33e0bb48c90b7016768818a6 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 13 Jul 2013 15:39:16 +0200 Subject: [PATCH] Added signalhandler in test suite, still issues. --- src/commands/default/building.py | 2 +- src/commands/default/general.py | 1 + src/commands/default/tests.py | 8 +++++++- src/objects/models.py | 1 + src/server/caches.py | 2 +- src/typeclasses/models.py | 30 +++++++++++++++--------------- src/utils/create.py | 3 +-- src/utils/idmapper/base.py | 1 + 8 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/commands/default/building.py b/src/commands/default/building.py index 2293363ef9..ed4dd6c211 100644 --- a/src/commands/default/building.py +++ b/src/commands/default/building.py @@ -153,7 +153,7 @@ class CmdSetObjAlias(MuxCommand): # save back to object. obj.aliases.add(aliases) # we treat this as a re-caching (relevant for exits to re-build their exit commands with the correct aliases) - caller.msg("Aliases for '%s' are now %s." % (obj.key, str(obj.aliases))) + caller.msg("Alias(es) for '%s' set to %s." % (obj.key, str(obj.aliases))) class CmdCopy(ObjManipCommand): """ diff --git a/src/commands/default/general.py b/src/commands/default/general.py index 99ad4c8195..408616f8ec 100644 --- a/src/commands/default/general.py +++ b/src/commands/default/general.py @@ -220,6 +220,7 @@ class CmdGet(MuxCommand): if not self.args: caller.msg("Get what?") return + #print "general/get:", caller, caller.location, self.args, caller.location.contents obj = caller.search(self.args, location=caller.location) if not obj: return diff --git a/src/commands/default/tests.py b/src/commands/default/tests.py index c9ef9cc701..30972807a3 100644 --- a/src/commands/default/tests.py +++ b/src/commands/default/tests.py @@ -18,6 +18,12 @@ from django.utils.unittest import TestCase from src.players.player import Player from src.utils import create, utils, ansi +from django.db.models.signals import pre_save +from src.server.caches import field_pre_save +pre_save.connect(field_pre_save, dispatch_uid="fieldcache") + +# set up signal here since we are not starting the server + _RE = re.compile(r"^\+|-+\+|\+-+|--*|\|", re.MULTILINE) #------------------------------------------------------------ @@ -171,7 +177,7 @@ class TestBuilding(CommandTest): CID = 6 def test_cmds(self): self.call(building.CmdCreate(), "/drop TestObj1", "You create a new Object: TestObj1.") - self.call(building.CmdSetObjAlias(), "TestObj1 = TestObj1b","Aliases for 'TestObj1' are now set to testobj1b.") + self.call(building.CmdSetObjAlias(), "TestObj1 = TestObj1b","Alias(es) for 'TestObj1' set to testobj1b.") self.call(building.CmdCopy(), "TestObj1 = TestObj2;TestObj2b, TestObj3;TestObj3b", "Copied TestObj1 to 'TestObj3' (aliases: ['TestObj3b']") self.call(building.CmdSetAttribute(), "Obj6/test1=\"value1\"", "Created attribute Obj6/test1 = \"value1\"") self.call(building.CmdSetAttribute(), "Obj6b/test2=\"value2\"", "Created attribute Obj6b/test2 = \"value2\"") diff --git a/src/objects/models.py b/src/objects/models.py index eca42c30c8..8b3bff946b 100644 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -792,6 +792,7 @@ class ObjectDB(TypedObject): # Perform move try: + #print "move_to location:", destination _SA(self, "location", destination) except Exception: emit_to_obj.msg(errtxt % "location change") diff --git a/src/server/caches.py b/src/server/caches.py index b4d2707001..b3a8d9e86e 100644 --- a/src/server/caches.py +++ b/src/server/caches.py @@ -38,7 +38,7 @@ else: def hashid(obj, suffix=""): """ - Returns a per-class unique that combines the object's + Returns a per-class unique hash that combines the object's class name with its idnum and creation time. This makes this id unique also between different typeclassed entities such as scripts and objects (which may still have the same id). diff --git a/src/typeclasses/models.py b/src/typeclasses/models.py index f4cd8b2219..fcd081daff 100644 --- a/src/typeclasses/models.py +++ b/src/typeclasses/models.py @@ -130,20 +130,20 @@ class Attribute(SharedMemoryModel): # value = self.attr and del self.attr respectively (where self # is the object in question). - # key property (wraps db_key) - #@property - def __key_get(self): - "Getter. Allows for value = self.key" - return get_field_cache(self, "key") - #@key.setter - def __key_set(self, value): - "Setter. Allows for self.key = value" - set_field_cache(self, "key", value) - #@key.deleter - def __key_del(self): - "Deleter. Allows for del self.key" - raise Exception("Cannot delete attribute key!") - key = property(__key_get, __key_set, __key_del) + ## key property (wraps db_key) + ##@property + #def __key_get(self): + # "Getter. Allows for value = self.key" + # return get_field_cache(self, "key") + ##@key.setter + #def __key_set(self, value): + # "Setter. Allows for self.key = value" + # set_field_cache(self, "key", value) + ##@key.deleter + #def __key_del(self): + # "Deleter. Allows for del self.key" + # raise Exception("Cannot delete attribute key!") + #key = property(__key_get, __key_set, __key_del) # obj property (wraps db_obj) #@property @@ -232,7 +232,7 @@ class Attribute(SharedMemoryModel): # def __str__(self): - return smart_str("%s(%s)" % (_GA(self, "db_key", _GA(self, "id")))) + return smart_str("%s(%s)" % (_GA(self, "db_key"), _GA(self, "id"))) def __unicode__(self): return u"%s(%s)" % (_GA(self, "db_key", _GA(self, "id"))) diff --git a/src/utils/create.py b/src/utils/create.py index 3772538b08..07d13a66dc 100644 --- a/src/utils/create.py +++ b/src/utils/create.py @@ -137,9 +137,8 @@ def create_object(typeclass, key=None, location=None, else: new_object.home = settings.CHARACTER_DEFAULT_HOME - if location: - new_object.move_to(location, quiet=True) + new_object.move_to(location, quiet=True) else: # rooms would have location=None. new_object.location = None diff --git a/src/utils/idmapper/base.py b/src/utils/idmapper/base.py index ad17defb7c..40ae6bf5cc 100755 --- a/src/utils/idmapper/base.py +++ b/src/utils/idmapper/base.py @@ -96,6 +96,7 @@ class SharedMemoryModelBase(ModelBase): def _set(cls, fname, value): "Wrapper for setting database field" + #print "_set:", fname if hasattr(value, "dbobj"): value = _GA(value, "dbobj") elif isinstance(value, basestring) and (value.isdigit() or value.startswith("#")):