First version where test suite validates. Caching is still not fully active (especially attribute lookup), OOBhandler is untested.

This commit is contained in:
Griatch 2013-09-22 22:57:03 +02:00
parent 8b1afa7043
commit 272a6ddc2d
3 changed files with 7 additions and 9 deletions

View file

@ -1331,20 +1331,20 @@ class CmdTypeclass(MuxCommand):
caller.msg("This object cannot have a type at all!")
return
is_same = obj.is_typeclass(typeclass)
is_same = obj.is_typeclass(typeclass, exact=True)
if is_same and not 'force' in self.switches:
string = "%s already has the typeclass '%s'. Use /force to override." % (obj.name, typeclass)
else:
reset = "reset" in self.switches
old_typeclass_path = obj.typeclass.path
old_typeclass_path = obj.typeclass_path
ok = obj.swap_typeclass(typeclass, clean_attributes=reset)
if ok:
if is_same:
string = "%s updated its existing typeclass (%s).\n" % (obj.name, obj.typeclass.path)
else:
string = "%s's changed typeclass from %s to %s.\n" % (obj.name,
string = "%s changed typeclass from %s to %s.\n" % (obj.name,
old_typeclass_path,
obj.typeclass.path)
obj.typeclass_path)
string += "Creation hooks were run."
if reset:
string += " All old attributes where deleted before the swap."
@ -1356,7 +1356,6 @@ class CmdTypeclass(MuxCommand):
string += "\nCould not swap '%s' (%s) to typeclass '%s'." % (obj.name,
old_typeclass_path,
typeclass)
caller.msg(string)

View file

@ -229,8 +229,8 @@ class TestBuilding(CommandTest):
self.call(building.CmdUnLink(), "TestExit1", "Former exit TestExit1 no longer links anywhere.")
self.call(building.CmdSetHome(), "Obj6 = Room6b", "Obj6's home location was changed from Room6")
self.call(building.CmdListCmdSets(), "", "<DefaultCharacter (Union, prio 0, perm)>:")
self.call(building.CmdTypeclass(), "Obj6 = src.objects.objects.Character",
"Obj6's changed typeclass from src.commands.default.tests.TestObjectClass to src.objects.objects.Character")
self.call(building.CmdTypeclass(), "Obj6 = src.objects.objects.Exit",
"Obj6 changed typeclass from src.commands.default.tests.TestObjectClass to src.objects.objects.Exit")
self.call(building.CmdLock(), "Obj6 = test:perm(Immortals)", "Added lock 'test:perm(Immortals)' to Obj6.")
self.call(building.CmdExamine(), "Obj6", "Name/key: Obj6")
self.call(building.CmdFind(), "TestRoom1", "One Match")

View file

@ -766,7 +766,6 @@ class TypedObject(SharedMemoryModel):
#
#
# these are identifiers for fast Attribute access and caching
_typeclass_paths = settings.OBJECT_TYPECLASS_PATHS
def __eq__(self, other):
@ -1001,7 +1000,7 @@ class TypedObject(SharedMemoryModel):
logger.log_trace()
return typeclass
def is_typeclass(self, typeclass, exact=False):
def is_typeclass(self, typeclass, exact=True):
"""
Returns true if this object has this type
OR has a typeclass which is an subclass of