Multiple fixes to ev and utils:

Made utils.variable_from_module more generic (it can now load pretty much any form of module it's given and also supports searching and returning multiple variables).

Removed the variable-load functionality from utils.load_module; this is now purely a loader - use variable_from_module instead.

I found out that one couldn't import from src.commands.default due to the __init__ file being restrictive for the sake of the ev API. Removed that and instead imported the default commands into ev.py with the help of utils.variable_from_module instead. Some more fixes in ev followed on this.
This commit is contained in:
Griatch 2012-04-22 12:23:42 +02:00
parent 3306e36d82
commit 4678234e9a
11 changed files with 211 additions and 188 deletions

View file

@ -47,7 +47,7 @@ __all__ = ("cmdhandler",)
# This decides which command parser is to be used.
# You have to restart the server for changes to take effect.
_COMMAND_PARSER = utils.mod_import(*settings.COMMAND_PARSER.rsplit('.', 1))
_COMMAND_PARSER = utils.variable_from_module(*settings.COMMAND_PARSER.rsplit('.', 1))
# System command names - import these variables rather than trying to
# remember the actual string constants. If not defined, Evennia

View file

@ -1,27 +1,4 @@
"""
Groups all default commands for access from the API.
To use via ev API, import this module with
from ev import default_cmds,
you can then access the command classes as members of default_cmds.
This package contains all default commands of Evennia, grouped after category.
"""
from src.commands.default.cmdset_default import DefaultCmdSet
from src.commands.default.cmdset_ooc import OOCCmdSet
from src.commands.default.cmdset_unloggedin import UnloggedinCmdSet
from src.commands.default.muxcommand import MuxCommand
from src.commands.default.admin import *
from src.commands.default.batchprocess import *
from src.commands.default.building import *
from src.commands.default.comms import *
from src.commands.default.general import *
from src.commands.default.help import *
from src.commands.default import syscommands
from src.commands.default.system import *
from src.commands.default.unloggedin import *
del cmdset_default, cmdset_ooc, cmdset_unloggedin, muxcommand
del admin, batchprocess, building, comms, general,
del help, system, unloggedin

View file

@ -35,9 +35,6 @@ class DefaultCmdSet(CmdSet):
self.add(help.CmdSetHelp())
# System commands
self.add(system.CmdReload())
self.add(system.CmdReset())
self.add(system.CmdShutdown())
self.add(system.CmdPy())
self.add(system.CmdScripts())
self.add(system.CmdObjects())
@ -51,9 +48,7 @@ class DefaultCmdSet(CmdSet):
self.add(admin.CmdBoot())
self.add(admin.CmdBan())
self.add(admin.CmdUnban())
self.add(admin.CmdDelPlayer())
self.add(admin.CmdEmit())
self.add(admin.CmdNewPassword())
self.add(admin.CmdPerm())
self.add(admin.CmdWall())

View file

@ -6,20 +6,20 @@ a Player object as caller rather than a Character.
"""
from src.commands.cmdset import CmdSet
from src.commands.default import help, comms, general, admin
from src.commands.default import help, comms, general, admin, system
class OOCCmdSet(CmdSet):
"""
Implements the player command set.
"""
key = "DefaultOOC"
priority = -5
def at_cmdset_creation(self):
"Populates the cmdset"
# general commands
# General commands
self.add(general.CmdOOCLook())
self.add(general.CmdIC())
self.add(general.CmdOOC())
@ -27,11 +27,15 @@ class OOCCmdSet(CmdSet):
self.add(general.CmdQuit())
self.add(general.CmdPassword())
# help command
# Help command
self.add(help.CmdHelp())
# admin commands
self.add(admin.CmdBoot())
# system commands
self.add(system.CmdReload())
self.add(system.CmdReset())
self.add(system.CmdShutdown())
# Admin commands
self.add(admin.CmdDelPlayer())
self.add(admin.CmdNewPassword())

View file

@ -15,7 +15,7 @@ __all__ = ("CmdHome", "CmdLook", "CmdPassword", "CmdNick",
"CmdSay", "CmdPose", "CmdEncoding", "CmdAccess",
"CmdOOCLook", "CmdIC", "CmdOOC")
AT_SEARCH_RESULT = utils.mod_import(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
AT_SEARCH_RESULT = utils.variable_from_module(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
BASE_PLAYER_TYPECLASS = settings.BASE_PLAYER_TYPECLASS
class CmdHome(MuxCommand):