Make more commands honor settings.COMMAND_DEFAULT_CLASS

As suggested in mygame\commands\command.py, I'm overriding COMMAND_DEFAULT_CLASS in settings.py to try to make sweeping changes. Having certain commands inherit directly from the base Command class thwarts this.

The only difference between Command and MuxCommand is that MuxCommand defines some custom parsing, but that's overridden by these commands anyway, so there should be no practical difference.

The import change in game_template/commands/command.py was required to fix an exception on server reload caused by the channelhandler.py change (I guess something to do with import order?)
This commit is contained in:
Tim Chaplin 2020-12-27 11:45:25 -05:00
parent f39dcb8786
commit 9923a0763d
4 changed files with 9 additions and 8 deletions

View file

@ -25,7 +25,7 @@ _DEFAULT_WIDTH = settings.CLIENT_DEFAULT_WIDTH
_SEP = "|C" + "-" * _DEFAULT_WIDTH + "|n"
class CmdHelp(Command):
class CmdHelp(COMMAND_DEFAULT_CLASS):
"""
View help or a list of topics

View file

@ -24,7 +24,7 @@ does this for you.
"""
from django.conf import settings
from evennia.commands import cmdset, command
from evennia.commands import cmdset
from evennia.utils.logger import tail_log_file
from evennia.utils.utils import class_from_module
from django.utils.translation import gettext as _
@ -35,9 +35,9 @@ from django.utils.translation import gettext as _
_CHANNEL_HANDLER_CLASS = None
_CHANNEL_COMMAND_CLASS = None
_CHANNELDB = None
_COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS)
class ChannelCommand(command.Command):
class ChannelCommand(_COMMAND_DEFAULT_CLASS):
"""
{channelkey} channel

View file

@ -5,7 +5,7 @@ Commands describe the input the account can do to the game.
"""
from evennia import Command as BaseCommand
from evennia.commands.command import Command as BaseCommand
# from evennia import default_cmds

View file

@ -48,7 +48,7 @@ import re
from django.conf import settings
from evennia import Command, CmdSet
from evennia.utils import is_iter, fill, dedent, logger, justify, to_str
from evennia.utils import is_iter, fill, dedent, logger, justify, to_str, utils
from evennia.utils.ansi import raw
from evennia.commands import cmdhandler
@ -58,6 +58,7 @@ _CMD_NOMATCH = cmdhandler.CMD_NOMATCH
_CMD_NOINPUT = cmdhandler.CMD_NOINPUT
_RE_GROUP = re.compile(r"\".*?\"|\'.*?\'|\S*")
_COMMAND_DEFAULT_CLASS = utils.class_from_module(settings.COMMAND_DEFAULT_CLASS)
# use NAWS in the future?
_DEFAULT_WIDTH = settings.CLIENT_DEFAULT_WIDTH
@ -171,7 +172,7 @@ _MSG_REDO = "Redid one step."
# -------------------------------------------------------------
class CmdSaveYesNo(Command):
class CmdSaveYesNo(_COMMAND_DEFAULT_CLASS):
"""
Save the editor state on quit. This catches
nomatches (defaults to Yes), and avoid saves only if
@ -217,7 +218,7 @@ class SaveYesNoCmdSet(CmdSet):
# -------------------------------------------------------------
class CmdEditorBase(Command):
class CmdEditorBase(_COMMAND_DEFAULT_CLASS):
"""
Base parent for editor commands
"""