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.

This commit is contained in:
Griatch 2013-07-02 15:50:42 +02:00
parent 47a324f720
commit 92a8e39de5
4 changed files with 8 additions and 6 deletions

View file

@ -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)")

View file

@ -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

View file

@ -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):
"""

View file

@ -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