Fixed the loading of the menu_login contrib, doing some cleanup in the error reporting at the same time. Also added evennia to the search path for cmdsets and typeclasses so that one can give the path to e.g contrib when loading.

This commit is contained in:
Griatch 2015-05-17 00:49:41 +02:00
parent e37079aa5b
commit 64c6d06d0f
4 changed files with 13 additions and 18 deletions

View file

@ -66,7 +66,7 @@ def cmdparser(raw_string, cmdset, caller, match_index=None):
return (cmdname, args, cmdobj, cmdlen, mratio)
if not raw_string:
return None
return []
matches = []

View file

@ -119,7 +119,6 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
#print "importing %s: _CACHED_CMDSETS=%s" % (python_path, _CACHED_CMDSETS)
wanted_cache_key = python_path
cmdsetclass = _CACHED_CMDSETS.get(wanted_cache_key, None)
errstring = ""
if not cmdsetclass:
#print "cmdset '%s' not in cache. Reloading %s on %s." % (wanted_cache_key, python_path, cmdsetobj)
# Not in cache. Reload from disk.
@ -130,21 +129,22 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
#instantiate the cmdset (and catch its errors)
if callable(cmdsetclass):
cmdsetclass = cmdsetclass(cmdsetobj)
errstring = ""
return cmdsetclass
except ImportError, e:
logger.log_trace()
#logger.log_trace()
errstring += _("Error loading cmdset {path}: {error}")
errstring = errstring.format(path=python_path, error=e)
except KeyError:
logger.log_trace()
#logger.log_trace()
errstring += _("Error in loading cmdset: No cmdset class '{classname}' in {path}.")
errstring = errstring.format(classname=classname, path=python_path)
except SyntaxError, e:
logger.log_trace()
#logger.log_trace()
errstring += _("SyntaxError encountered when loading cmdset '{path}': {error}.")
errstring = errstring.format(path=python_path, error=e)
except Exception, e:
logger.log_trace()
#logger.log_trace()
errstring += _("Compile/Run error when loading cmdset '{path}': {error}.")
errstring = errstring.format(path=python_path, error=e)

View file

@ -302,26 +302,21 @@ node1a = MenuNode("node1a", text="Please enter your account name (empty to abort
links=["START", "node1b"],
helptext=["Enter the account name you previously registered with."],
keywords=[CMD_NOINPUT, CMD_NOMATCH],
selectcmds=[CmdBackToStart, CmdUsernameSelect],
nodefaultcmds=True) # if we don't, default help/look will be triggered by names starting with l/h ...
selectcmds=[CmdBackToStart, CmdUsernameSelect])
node1b = MenuNode("node1b", text="Please enter your password (empty to go back).",
links=["node1a", "END"],
keywords=[CMD_NOINPUT, CMD_NOMATCH],
selectcmds=[CmdPasswordSelectBack, CmdPasswordSelect],
nodefaultcmds=True)
selectcmds=[CmdPasswordSelectBack, CmdPasswordSelect])
node2a = MenuNode("node2a", text="Please enter your desired account name (empty to abort).",
links=["START", "node2b"],
helptext="Account name can max be 30 characters or fewer. Letters, spaces, digits and @/./+/-/_ only.",
keywords=[CMD_NOINPUT, CMD_NOMATCH],
selectcmds=[CmdBackToStart, CmdUsernameCreate],
nodefaultcmds=True)
selectcmds=[CmdBackToStart, CmdUsernameCreate])
node2b = MenuNode("node2b", text="Please enter your password (empty to go back).",
links=["node2a", "START"],
helptext="Try to pick a long and hard-to-guess password.",
keywords=[CMD_NOINPUT, CMD_NOMATCH],
selectcmds=[CmdPasswordCreateBack, CmdPasswordCreate],
nodefaultcmds=True)
selectcmds=[CmdPasswordCreateBack, CmdPasswordCreate])
node3 = MenuNode("node3", text=LOGIN_SCREEN_HELP,
links=["START"],
helptext="",
@ -348,7 +343,7 @@ class CmdUnloggedinLook(Command):
to the menu's own look command..
"""
key = CMD_LOGINSTART
aliases = ["look", "l"]
# obs, this should NOT have aliases for look or l, this will clash with the menu version!
locks = "cmd:all()"
arg_regex = r"^$"

View file

@ -295,7 +295,7 @@ CMDSET_CHARACTER = "commands.default_cmdsets.CharacterCmdSet"
# Command set for players without a character (ooc)
CMDSET_PLAYER = "commands.default_cmdsets.PlayerCmdSet"
# Location to search for cmdsets if full path not given
CMDSET_PATHS = ["commands"]
CMDSET_PATHS = ["commands", "evennia", "contribs"]
# Line editor path. Points to a line editor class that commands may use to give
# users extended editing control. See the default path for a reference implementation
@ -313,7 +313,7 @@ SERVER_SESSION_CLASS = "evennia.server.serversession.ServerSession"
# immediately entered path fail to find a typeclass. It allows for
# shorter input strings. They must either base off the game directory
# or start from the evennia library.
TYPECLASS_PATHS = ["typeclasses", "evennia.contrib", "evennia.contrib.tutorial_examples"]
TYPECLASS_PATHS = ["typeclasses", "evennia", "evennia.contrib", "evennia.contrib.tutorial_examples"]
# Typeclass for player objects (linked to a character) (fallback)
BASE_PLAYER_TYPECLASS = "typeclasses.players.Player"