From 92a8e39de5282a1e27efa3cfce9e03f23465fe18 Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 2 Jul 2013 15:50:42 +0200 Subject: [PATCH] Changed how the cmdset's errmessage is propagated. Adding failing cmdsets added ErrorCmdsets to the cmdhandler. This was for callback reasons, but it clutters up things for no good reason. --- contrib/tutorial_world/objects.py | 1 + src/commands/cmdhandler.py | 2 +- src/commands/cmdset.py | 3 ++- src/commands/cmdsethandler.py | 8 ++++---- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/contrib/tutorial_world/objects.py b/contrib/tutorial_world/objects.py index 08a9f1ab3e..2d033372a3 100644 --- a/contrib/tutorial_world/objects.py +++ b/contrib/tutorial_world/objects.py @@ -561,6 +561,7 @@ class CrumblingWall(TutorialObject, Exit): self.aliases = ["secret passage", "passage", "crack", "opening", "secret door"] # this is assigned first when pushing button, so assign this at creation time! + self.db.destination = 2 # locks on the object directly transfer to the exit "command" self.locks.add("cmd:not locattr(is_dark)") diff --git a/src/commands/cmdhandler.py b/src/commands/cmdhandler.py index bbb93b7b5d..44e6860a3d 100644 --- a/src/commands/cmdhandler.py +++ b/src/commands/cmdhandler.py @@ -141,7 +141,7 @@ def get_and_merge_cmdsets(caller): # weed out all non-found sets cmdsets = yield [cmdset for cmdset in cmdsets if cmdset and cmdset.key!="Empty"] # report cmdset errors to user (these should already have been logged) - yield [caller.msg(cmdset.message) for cmdset in cmdsets if cmdset.key == "_CMDSET_ERROR"] + yield [caller.msg(cmdset.errmessage) for cmdset in cmdsets if cmdset.key == "_CMDSET_ERROR"] if cmdsets: # we group and merge all same-prio cmdsets separately (this avoids order-dependent diff --git a/src/commands/cmdset.py b/src/commands/cmdset.py index ebab1aad09..1346e2f091 100644 --- a/src/commands/cmdset.py +++ b/src/commands/cmdset.py @@ -128,9 +128,10 @@ class CmdSet(object): no_objs = False no_channels = False permanent = False + errmessage = "" # pre-store properties to duplicate straight off to_duplicate = ("key", "cmdsetobj", "no_exits", "no_objs", "no_channels", "permanent", - "mergetype", "priority", "duplicates") + "mergetype", "priority", "duplicates", "errmessage") def __init__(self, cmdsetobj=None, key=None): """ diff --git a/src/commands/cmdsethandler.py b/src/commands/cmdsethandler.py index 4c19164f31..59a3d658b1 100644 --- a/src/commands/cmdsethandler.py +++ b/src/commands/cmdsethandler.py @@ -76,7 +76,7 @@ _CACHED_CMDSETS = {} class _ErrorCmdSet(CmdSet): "This is a special cmdset used to report errors" key = "_CMDSET_ERROR" - message = "Error when loading cmdset." + errmessage = "Error when loading cmdset." def import_cmdset(python_path, cmdsetobj, emit_to_obj=None, no_logging=False): """ @@ -130,7 +130,7 @@ def import_cmdset(python_path, cmdsetobj, emit_to_obj=None, no_logging=False): if emit_to_obj and not ServerConfig.objects.conf("server_starting_mode"): object.__getattribute__(emit_to_obj, "msg")(errstring) err_cmdset = _ErrorCmdSet() - err_cmdset.message = errstring + err_cmdset.errmessage = errstring return err_cmdset # classes @@ -283,7 +283,7 @@ class CmdSetHandler(object): elif isinstance(cmdset, basestring): # this is (maybe) a python path. Try to import from cache. cmdset = self._import_cmdset(cmdset) - if cmdset: + if cmdset and cmdset.key != '_CMDSET_ERROR': if permanent and cmdset.key != '_CMDSET_ERROR': # store the path permanently cmdset.permanent = True @@ -315,7 +315,7 @@ class CmdSetHandler(object): elif isinstance(cmdset, basestring): # this is (maybe) a python path. Try to import from cache. cmdset = self._import_cmdset(cmdset) - if cmdset: + if cmdset and cmdset.key != '_CMDSET_ERROR': if self.cmdset_stack: self.cmdset_stack[0] = cmdset self.mergetype_stack[0] = cmdset.mergetype