Create fallback for default cmdsets that fail to load

This commit is contained in:
Tehom 2017-07-28 01:26:00 -04:00
parent 24c5ddecab
commit bafd069d97
2 changed files with 14 additions and 0 deletions

View file

@ -351,6 +351,14 @@ class CmdSetHandler(object):
elif path:
cmdset = self._import_cmdset(path)
if cmdset:
if cmdset.key == '_CMDSET_ERROR':
# If a cmdset fails to load, check if we have a fallback path to use
fallback_path = settings.CMDSET_FALLBACKS.get(path, None)
if fallback_path:
cmdset = self._import_cmdset(fallback_path)
# If no cmdset is returned from the fallback, we can't go further
if not cmdset:
continue
cmdset.permanent = cmdset.key != '_CMDSET_ERROR'
self.cmdset_stack.append(cmdset)

View file

@ -348,6 +348,12 @@ CMDSET_CHARACTER = "commands.default_cmdsets.CharacterCmdSet"
CMDSET_PLAYER = "commands.default_cmdsets.PlayerCmdSet"
# Location to search for cmdsets if full path not given
CMDSET_PATHS = ["commands", "evennia", "contribs"]
# Fallbacks for cmdset paths that fail to load. Note that if you change the path for your default cmdsets,
# you will also need to copy CMDSET_FALLBACKS after your change in your settings file for it to detect the change.
CMDSET_FALLBACKS = {CMDSET_CHARACTER: 'evennia.commands.default.cmdset_character.CharacterCmdSet',
CMDSET_PLAYER: 'evennia.commands.default.cmdset_player.PlayerCmdSet',
CMDSET_SESSION: 'evennia.commands.default.cmdset_session.SessionCmdSet',
CMDSET_UNLOGGEDIN: 'evennia.commands.default.cmdset_unloggedin.UnloggedinCmdSet'}
# Parent class for all default commands. Changing this class will
# modify all default commands, so do so carefully.
COMMAND_DEFAULT_CLASS = "evennia.commands.default.muxcommand.MuxCommand"