From e042366f3119d336db4599e25cc918f7f8972803 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 25 Mar 2012 19:52:51 +0200 Subject: [PATCH] Removed the conf/ modules, putting them into conf/examples instead, in line with other API changes. The gamesrc/ folder is now completely empty and all new modules have to be added explicitly. --- game/gamesrc/conf/examples/__init__.py | 0 .../conf/{ => examples}/at_initial_setup.py | 9 +++++- .../{ => examples}/at_server_startstop.py | 11 +++++-- .../conf/{ => examples}/connection_screens.py | 12 +++++-- game/gamesrc/conf/{ => examples}/lockfuncs.py | 10 ++++-- game/gamesrc/conf/{ => examples}/mssp.py | 32 ++++++++++++------- game/gamesrc/conf/{ => examples}/oobfuncs.py | 3 ++ src/server/mssp.py | 5 +-- src/server/server.py | 3 +- src/settings_default.py | 13 ++++---- src/utils/utils.py | 4 +++ 11 files changed, 72 insertions(+), 30 deletions(-) create mode 100644 game/gamesrc/conf/examples/__init__.py rename game/gamesrc/conf/{ => examples}/at_initial_setup.py (72%) rename game/gamesrc/conf/{ => examples}/at_server_startstop.py (75%) rename game/gamesrc/conf/{ => examples}/connection_screens.py (87%) rename game/gamesrc/conf/{ => examples}/lockfuncs.py (80%) rename game/gamesrc/conf/{ => examples}/mssp.py (85%) rename game/gamesrc/conf/{ => examples}/oobfuncs.py (93%) diff --git a/game/gamesrc/conf/examples/__init__.py b/game/gamesrc/conf/examples/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/game/gamesrc/conf/at_initial_setup.py b/game/gamesrc/conf/examples/at_initial_setup.py similarity index 72% rename from game/gamesrc/conf/at_initial_setup.py rename to game/gamesrc/conf/examples/at_initial_setup.py index cf15ea02a..12d68a50e 100644 --- a/game/gamesrc/conf/at_initial_setup.py +++ b/game/gamesrc/conf/examples/at_initial_setup.py @@ -1,4 +1,12 @@ """ +At_initial_setup module template + +Copy this module up one level to /gamesrc/conf, name it what you like +and then use it as a template to modify. + +Then edit settings.AT_INITIAL_SETUP_HOOK_MODULE to point to your new +module. + Custom at_initial_setup method. This allows you to hook special modifications to the initial server startup process. Note that this will only be run once - when the server starts up for the very first @@ -10,7 +18,6 @@ will be called without arguments. Note that tracebacks in this module will be QUIETLY ignored, so make sure to check it well to make sure it does what you expect it to. -This module is selected by settings.AT_INITIAL_SETUP_HOOK_MODULE. """ def at_initial_setup(): diff --git a/game/gamesrc/conf/at_server_startstop.py b/game/gamesrc/conf/examples/at_server_startstop.py similarity index 75% rename from game/gamesrc/conf/at_server_startstop.py rename to game/gamesrc/conf/examples/at_server_startstop.py index 19a5490d2..46a89d7cd 100644 --- a/game/gamesrc/conf/at_server_startstop.py +++ b/game/gamesrc/conf/examples/at_server_startstop.py @@ -1,4 +1,13 @@ """ + +At_server_startstop module template + +Copy this module one level up, to gamesrc/conf/, name it what you +will and use it as a template for your modifications. + +Then edit settings.AT_SERVER_STARTSTOP_MODULE to point to your new +module. + This module contains functions that are imported and called by the server whenever it changes its running status. At the point these functions are run, all applicable hooks on individual objects have @@ -11,8 +20,6 @@ The module should define at least these global functions: at_server_start() at_server_stop() -The module used is defined by settings.AT_SERVER_STARTSTOP_MODULE. - """ def at_server_start(): diff --git a/game/gamesrc/conf/connection_screens.py b/game/gamesrc/conf/examples/connection_screens.py similarity index 87% rename from game/gamesrc/conf/connection_screens.py rename to game/gamesrc/conf/examples/connection_screens.py index a143cc8ef..5b25dc44e 100644 --- a/game/gamesrc/conf/connection_screens.py +++ b/game/gamesrc/conf/examples/connection_screens.py @@ -1,4 +1,13 @@ """ +Connect screen module template + +Copy this module one level up, to gamesrc/conf/, name it what +you want and modify it to your liking. + +Then you set settings.CONNECTION_SCREEN_MODULE to point to your +new module. + + This module holds textual connection screen definitions. All global string variables (only) in this module are read by Evennia and assumed to define a Connection screen. @@ -14,9 +23,6 @@ After adding new connection screens to this module you must either reboot or reload the server to make them available. -You can change which module is used with -settings.CONNECTION_SCREEN_MODULE. - """ from src.utils import utils diff --git a/game/gamesrc/conf/lockfuncs.py b/game/gamesrc/conf/examples/lockfuncs.py similarity index 80% rename from game/gamesrc/conf/lockfuncs.py rename to game/gamesrc/conf/examples/lockfuncs.py index d603cb96d..717ac8559 100644 --- a/game/gamesrc/conf/lockfuncs.py +++ b/game/gamesrc/conf/examples/lockfuncs.py @@ -1,8 +1,12 @@ """ -This is an example module for holding custom lock funcs, used in -in-game locks. The modules available to use as lockfuncs are defined -in the tuple settings.LOCK_FUNC_MODULES. +Lockfuncs module template + +Copy this module one level up, to gamesrc/conf/, name it what +you will and edit it to your liking. + +Then add the new module's path to the end of the tuple +defined in settings.LOCK_FUNC_MODULES. All functions defined globally in this module are assumed to be available for use in lockstrings to determine access. See diff --git a/game/gamesrc/conf/mssp.py b/game/gamesrc/conf/examples/mssp.py similarity index 85% rename from game/gamesrc/conf/mssp.py rename to game/gamesrc/conf/examples/mssp.py index 8cdf0805b..733cf4a52 100644 --- a/game/gamesrc/conf/mssp.py +++ b/game/gamesrc/conf/examples/mssp.py @@ -1,15 +1,23 @@ -# -# MSSP (Mud Server Status Protocol) meta information -# -# MUD website listings (that you have registered with) can use this -# information to keep up-to-date with your game stats as you change -# them. Also number of currently active players and uptime will -# automatically be reported. You don't have to fill in everything -# (and most are not used by all crawlers); leave the default -# if so needed. You need to @reload the game before updated -# information is made available to crawlers (reloading does not -# affect uptime). -# +""" + +MSSP module template + +Copy this module one level up, to gamesrc/conf/, name it +what you want and edit it to your satisfaction. + +Then change settings.MSSP_META_MODULE to point to your new module. + + MSSP (Mud Server Status Protocol) meta information + + MUD website listings (that you have registered with) can use this + information to keep up-to-date with your game stats as you change + them. Also number of currently active players and uptime will + automatically be reported. You don't have to fill in everything + (and most are not used by all crawlers); leave the default + if so needed. You need to @reload the game before updated + information is made available to crawlers (reloading does not + affect uptime). +""" MSSPTable = { diff --git a/game/gamesrc/conf/oobfuncs.py b/game/gamesrc/conf/examples/oobfuncs.py similarity index 93% rename from game/gamesrc/conf/oobfuncs.py rename to game/gamesrc/conf/examples/oobfuncs.py index db2d5b56c..5638f48c1 100644 --- a/game/gamesrc/conf/oobfuncs.py +++ b/game/gamesrc/conf/examples/oobfuncs.py @@ -1,4 +1,7 @@ """ + +** OBS This module is not yet used by Evennia ** + Example module holding functions for out-of-band protocols to import and map to given commands from the client. This module is selected by settings.OOB_FUNC_MODULE. diff --git a/src/server/mssp.py b/src/server/mssp.py index 65f991948..bb6bf2272 100644 --- a/src/server/mssp.py +++ b/src/server/mssp.py @@ -20,7 +20,7 @@ MSSP_VAL = chr(2) # try to get the customized mssp info, if it exists. -MSSPTable_CUSTOM = utils.variable_from_module("game.gamesrc.conf.mssp", "MSSPTable", default={}) +MSSPTable_CUSTOM = utils.variable_from_module(settings.MSSP_META_MODULE, "MSSPTable", default={}) class Mssp(object): """ @@ -167,7 +167,8 @@ class Mssp(object): "XTERM 256 COLORS": "0"} # update the static table with the custom one - self.mssp_table.update(MSSPTable_CUSTOM) + if MSSPTable_CUSTOM: + self.mssp_table.update(MSSPTable_CUSTOM) varlist = '' for variable, value in self.mssp_table.items(): diff --git a/src/server/server.py b/src/server/server.py index b9a850dad..ea974d136 100644 --- a/src/server/server.py +++ b/src/server/server.py @@ -163,7 +163,8 @@ class Evennia(object): [(p.typeclass, p.at_init()) for p in PlayerDB.get_all_cached_instances()] # call server hook. - SERVER_HOOK_MODULE.at_server_start() + if SERVER_HOOK_MODULE: + SERVER_HOOK_MODULE.at_server_start() def terminal_output(self): """ diff --git a/src/settings_default.py b/src/settings_default.py index aa3e33689..d4c81a792 100644 --- a/src/settings_default.py +++ b/src/settings_default.py @@ -157,19 +157,20 @@ SEARCH_AT_MULTIMATCH_INPUT = "src.commands.cmdparser.at_multimatch_input" # The module holding text strings for the connection screen. # This module should contain one or more variables # with strings defining the look of the screen. -CONNECTION_SCREEN_MODULE = "game.gamesrc.conf.connection_screens" +CONNECTION_SCREEN_MODULE = "src.commands.connection_screen" # An option al module that, if existing, must hold a function # named at_initial_setup(). This hook method can be used to customize # the server's initial setup sequence (the very first startup of the system). # The check will fail quietly if module doesn't exist or fails to load. -AT_INITIAL_SETUP_HOOK_MODULE = "game.gamesrc.conf.at_initial_setup" +AT_INITIAL_SETUP_HOOK_MODULE = "" # Module holding at_server_start(), at_server_reload() and # at_server_stop() methods. These methods will be called every time # the server starts, reloads and resets/stops. -AT_SERVER_STARTSTOP_MODULE = "game.gamesrc.conf.at_server_startstop" +AT_SERVER_STARTSTOP_MODULE = "" # Module holding server-side functions for out-of-band protocols to call. -OOB_FUNC_MODULE = "game.gamesrc.conf.oobfuncs" - +OOB_FUNC_MODULE = "" +# Module holding MSSP meta data +MSSP_META_MODULE = "" ################################################### # Default command sets @@ -258,7 +259,7 @@ PERMISSION_HIERARCHY = ("Players","PlayerHelpers","Builders", "Wizards", "Immort PERMISSION_PLAYER_DEFAULT = "Players" # Tuple of modules implementing lock functions. All callable functions # inside these modules will be available as lock functions. -LOCK_FUNC_MODULES = ("src.locks.lockfuncs","game.gamesrc.conf.lockfuncs") +LOCK_FUNC_MODULES = ("src.locks.lockfuncs",) ################################################### diff --git a/src/utils/utils.py b/src/utils/utils.py index 02606be56..1ddca2cc3 100644 --- a/src/utils/utils.py +++ b/src/utils/utils.py @@ -566,6 +566,8 @@ def mod_import(mod_path, propname=None): for line in errmsg.splitlines(): log.msg('[EE] %s' % line) + if not mod_path: + return None # first try to import as a python path try: mod = __import__(mod_path, fromlist=["None"]) @@ -610,6 +612,8 @@ def variable_from_module(modpath, variable, default=None): If module cannot be imported or variable not found, default is returned. """ + if not modpath: + return None try: mod = __import__(modpath, fromlist=["None"]) return mod.__dict__.get(variable, default)