Fix caching error in new cmdset merge regime. Removed debug messages.

This commit is contained in:
Griatch 2016-10-15 23:22:33 +02:00
parent a61a33e87d
commit 1d6873eef4
3 changed files with 2 additions and 12 deletions

View file

@ -273,26 +273,21 @@ def get_and_merge_cmdsets(caller, session, player, obj, callertype):
except AttributeError: except AttributeError:
returnValue(((None, None, None), [])) returnValue(((None, None, None), []))
print "callertype:", callertype
local_obj_cmdsets = [] local_obj_cmdsets = []
if callertype == "session": if callertype == "session":
# we are calling the command from the session level # we are calling the command from the session level
report_to = session report_to = session
current, cmdsets = yield _get_cmdsets(session) current, cmdsets = yield _get_cmdsets(session)
print "session cmdsets:", len(cmdsets)
if player: # this automatically implies logged-in if player: # this automatically implies logged-in
pcurrent, player_cmdsets = yield _get_cmdsets(player) pcurrent, player_cmdsets = yield _get_cmdsets(player)
print "player cmdsets:", len(player_cmdsets)
cmdsets += player_cmdsets cmdsets += player_cmdsets
current = current + pcurrent current = current + pcurrent
if obj: if obj:
ocurrent, obj_cmdsets = yield _get_cmdsets(obj) ocurrent, obj_cmdsets = yield _get_cmdsets(obj)
print "obj_cmdsets:", len(obj_cmdsets), [cmdset.key for cmdset in obj_cmdsets]
current = current + ocurrent current = current + ocurrent
cmdsets += obj_cmdsets cmdsets += obj_cmdsets
if not current.no_objs: if not current.no_objs:
local_obj_cmdsets = yield _get_local_obj_cmdsets(obj) local_obj_cmdsets = yield _get_local_obj_cmdsets(obj)
print "local_obj_cmdsets:", len(local_obj_cmdsets), [cmdset.key for cmdset in local_obj_cmdsets]
if current.no_exits: if current.no_exits:
# filter out all exits # filter out all exits
local_obj_cmdsets = [cmdset for cmdset in local_obj_cmdsets if cmdset.key != "ExitCmdSet"] local_obj_cmdsets = [cmdset for cmdset in local_obj_cmdsets if cmdset.key != "ExitCmdSet"]
@ -300,12 +295,9 @@ def get_and_merge_cmdsets(caller, session, player, obj, callertype):
if not current.no_channels: if not current.no_channels:
# also objs may have channels # also objs may have channels
channel_cmdsets = yield _get_channel_cmdset(obj) channel_cmdsets = yield _get_channel_cmdset(obj)
print "obj channel cmdsets:", len(channel_cmdsets), [cmdset.key if cmdset else cmdset for cmdset in channel_cmdsets]
cmdsets += channel_cmdsets cmdsets += channel_cmdsets
if not current.no_channels: if not current.no_channels:
channel_cmdsets = yield _get_channel_cmdset(player) channel_cmdsets = yield _get_channel_cmdset(player)
print "player channel cmdsets:", len(channel_cmdsets), [cmdset.key for cmdset in channel_cmdsets]
print channel_cmdsets[0].commands
cmdsets += channel_cmdsets cmdsets += channel_cmdsets
elif callertype == "player": elif callertype == "player":
@ -354,7 +346,6 @@ def get_and_merge_cmdsets(caller, session, player, obj, callertype):
if cmdsets: if cmdsets:
# faster to do tuple on list than to build tuple directly # faster to do tuple on list than to build tuple directly
mergehash = tuple([id(cmdset) for cmdset in cmdsets]) mergehash = tuple([id(cmdset) for cmdset in cmdsets])
print "len(mergehash):", len(mergehash)
if mergehash in _CMDSET_MERGE_CACHE: if mergehash in _CMDSET_MERGE_CACHE:
# cached merge exist; use that # cached merge exist; use that
cmdset = _CMDSET_MERGE_CACHE[mergehash] cmdset = _CMDSET_MERGE_CACHE[mergehash]

View file

@ -68,7 +68,6 @@ class CmdLook(COMMAND_DEFAULT_CLASS):
target = self.caller.search(self.args) target = self.caller.search(self.args)
if not target: if not target:
return return
print "cmdlook:", id(self), id(self.cmdset)
self.msg(self.caller.at_look(target)) self.msg(self.caller.at_look(target))

View file

@ -1708,14 +1708,14 @@ class DefaultExit(DefaultObject):
""" """
if "force_init" in kwargs or not self.cmdset.has_cmdset("_exitset", must_be_default=True): if "force_init" in kwargs or not self.cmdset.has_cmdset("ExitCmdSet", must_be_default=True):
# we are resetting, or no exit-cmdset was set. Create one dynamically. # we are resetting, or no exit-cmdset was set. Create one dynamically.
self.cmdset.add_default(self.create_exit_cmdset(self), permanent=False) self.cmdset.add_default(self.create_exit_cmdset(self), permanent=False)
def at_init(self): def at_init(self):
""" """
This is called when this objects is re-loaded from cache. When This is called when this objects is re-loaded from cache. When
that happens, we make sure to remove any old _exitset cmdset that happens, we make sure to remove any old ExitCmdSet cmdset
(this most commonly occurs when renaming an existing exit) (this most commonly occurs when renaming an existing exit)
""" """
self.cmdset.remove_default() self.cmdset.remove_default()