Adding a new API system to Evennia. This centralizes all access of the evennia driver through a single module "ev". Importing ev one should be able to access (and also importantly, easily explore) Evennia's API much easier. This API goes a long way to "flatten" the structure so that one doesn't need to remember how to find some method in a deeply nested subdirectory.

As part of this work, I have also written full listings of all available properties on Typeclassed objects (including those inherited in various ways). Should hopefully make things easier to find.
One can of course still import things directly from src/ as before. But this is a first step towards removing the "base" objects in game/gamesrc and instead making those accessible through the core API.
This commit is contained in:
Griatch 2012-03-24 23:02:45 +01:00
parent 7a2cdd3842
commit 0d01462077
24 changed files with 519 additions and 93 deletions

View file

@ -0,0 +1,19 @@
"""
Central package for importing the default commands from the API.
"""
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 *

View file

@ -15,6 +15,11 @@ from src.commands.default.muxcommand import MuxCommand
PERMISSION_HIERARCHY = [p.lower() for p in settings.PERMISSION_HIERARCHY]
# limit members for API inclusion
__all__ = ("CmdBoot", "CmdBan", "CmdUnban", "CmdDelPlayer", "CmdEmit", "CmdNewPassword",
"CmdPerm", "CmdWall")
class CmdBoot(MuxCommand):
"""
@boot

View file

@ -28,6 +28,9 @@ from src.commands.cmdset import CmdSet
from src.commands.default.muxcommand import MuxCommand
from src.utils import utils
# limit symbols for API inclusion
__all__ = ("CmdBatchCommands", "CmdBatchCode")
HEADER_WIDTH = 70
UTF8_ERROR = \
"""

View file

@ -11,6 +11,16 @@ from src.utils import create, utils, debug
from src.commands.default.muxcommand import MuxCommand
from src.commands.cmdhandler import get_and_merge_cmdsets
# limit symbol import for API
__all__ = ("ObjManipCommand", "CmdSetObjAlias", "CmdCopy",
"CmdCpAttr", "CmdMvAttr", "CmdCreate", "CmdDebug",
"CmdDesc", "CmdDestroy", "CmdDig", "CmdTunnel", "CmdLink",
"CmdUnLink", "CmdHome", "CmdListCmdSets", "CmdName",
"CmdOpen", "CmdSetAttribute", "CmdTypeclass", "CmdWipe",
"CmdLock", "CmdExamine", "CmdFind", "CmdTeleport",
"CmdScript")
# used by @find
CHAR_TYPECLASS = settings.BASE_CHARACTER_TYPECLASS

View file

@ -15,8 +15,8 @@ class UnloggedinCmdSet(CmdSet):
def at_cmdset_creation(self):
"Populate the cmdset"
self.add(unloggedin.CmdConnect())
self.add(unloggedin.CmdCreate())
self.add(unloggedin.CmdQuit())
self.add(unloggedin.CmdUnconnectedConnect())
self.add(unloggedin.CmdUnconnectedCreate())
self.add(unloggedin.CmdUnconnectedQuit())
self.add(unloggedin.CmdUnconnectedLook())
self.add(unloggedin.CmdUnconnectedHelp())

View file

@ -14,6 +14,13 @@ from src.comms.channelhandler import CHANNELHANDLER
from src.utils import create, utils
from src.commands.default.muxcommand import MuxCommand
# limit symbol import for API
__all__ = ("CommCommand", "CmdAddCom", "CmdDelCom", "CmdAllCom",
"CmdChannels", "CmdCdestroy", "CmdCBoot", "CmdCemit",
"CmdCWho", "CmdChannelCreate", "CmdCset", "CmdCdesc",
"CmdPage", "CmdIRC2Chan", "CmdIMC2Chan", "CmdIMCInfo",
"CmdIMCTell", "CmdRSS2Chan")
def find_channel(caller, channelname, silent=False, noaliases=False):
"""
Helper function for searching for a single channel with

View file

@ -9,6 +9,12 @@ from src.utils import utils
from src.objects.models import ObjectNick as Nick
from src.commands.default.muxcommand import MuxCommand
# limit symbol import for API
__all__ = ("CmdHome", "CmdLook", "CmdPassword", "CmdNick",
"CmdInventory", "CmdGet", "CmdDrop", "CmdQuit", "CmdWho",
"CmdSay", "CmdPose", "CmdEncoding", "CmdAccess",
"CmdOOCLook", "CmdIC", "CmdOOC")
AT_SEARCH_RESULT = utils.mod_import(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
BASE_PLAYER_TYPECLASS = settings.BASE_PLAYER_TYPECLASS

View file

@ -12,6 +12,10 @@ from src.help.models import HelpEntry
from src.utils import create
from src.commands.default.muxcommand import MuxCommand
# limit symbol import for API
__all__ = ("CmdHelp", "CmdSetHelp")
LIST_ARGS = ("list", "all")
SEP = "{C" + "-"*78 + "{n"

View file

@ -5,6 +5,9 @@ The command template for the default MUX-style command set
from src.utils import utils
from src.commands.command import Command
# limit symbol import for API
__all__ = ("MuxCommand",)
class MuxCommand(Command):
"""
This sets up the basis for a MUX command. The idea

View file

@ -18,6 +18,10 @@ from src.server.models import ServerConfig
from src.utils import create, logger, utils, gametime
from src.commands.default.muxcommand import MuxCommand
# limit symbol import for API
__all__ = ("CmdReload", "CmdReset", "CmdShutdown", "CmdPy",
"CmdScripts", "CmdObjects", "CmdService", "CmdVersion",
"CmdTime", "CmdServerLoad", "CmdPs")
class CmdReload(MuxCommand):
"""

View file

@ -15,9 +15,12 @@ from src.utils import create, logger, utils, ansi
from src.commands.default.muxcommand import MuxCommand
from src.commands.cmdhandler import CMD_LOGINSTART
# limit symbol import for API
__all__ = ("CmdUnconnectedConnect", "CmdUnconnectedCreate", "CmdUnconnectedQuit", "CmdUnconnectedLook", "CmdUnconnectedHelp")
CONNECTION_SCREEN_MODULE = settings.CONNECTION_SCREEN_MODULE
class CmdConnect(MuxCommand):
class CmdUnconnectedConnect(MuxCommand):
"""
Connect to the game.
@ -86,7 +89,7 @@ class CmdConnect(MuxCommand):
player.execute_cmd("look")
class CmdCreate(MuxCommand):
class CmdUnconnectedCreate(MuxCommand):
"""
Create a new account.
@ -215,7 +218,7 @@ its and @/./+/-/_ only.") # this echoes the restrictions made by django's auth m
session.msg(string % (traceback.format_exc()))
logger.log_errmsg(traceback.format_exc())
class CmdQuit(MuxCommand):
class CmdUnconnectedQuit(MuxCommand):
"""
We maintain a different version of the quit command
here for unconnected players for the sake of simplicity. The logged in