Add a plugin mechanism for the webserver with settings.WEB_PLUGIN_MODULE.
This commit is contained in:
parent
36c938b06a
commit
64c74c41a1
4 changed files with 39 additions and 1 deletions
29
evennia/game_template/server/conf/web_plugins.py
Normal file
29
evennia/game_template/server/conf/web_plugins.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"""
|
||||
Web plugin hooks.
|
||||
"""
|
||||
|
||||
|
||||
def at_webserver_root_creation(web_root):
|
||||
"""
|
||||
This is called as the web server has finished building its default
|
||||
path tree. At this point, the media/ and static/ URIs have already
|
||||
been added to the web root.
|
||||
|
||||
Args:
|
||||
web_root (twisted.web.resource.Resource): The root
|
||||
resource of the URI tree. Use .putChild() to
|
||||
add new subdomains to the tree.
|
||||
|
||||
Returns:
|
||||
web_root (twisted.web.resource.Resource): The potentially
|
||||
modified root structure.
|
||||
|
||||
Example:
|
||||
from twisted.web import static
|
||||
my_page = static.File("web/mypage/")
|
||||
my_page.indexNames = ["index.html"]
|
||||
web_root.putChild("mypage", my_page)
|
||||
|
||||
"""
|
||||
return web_root
|
||||
|
||||
|
|
@ -48,8 +48,9 @@ SERVER_RESTART = os.path.join(settings.GAME_DIR, "server", 'server.restart')
|
|||
# module containing hook methods called during start_stop
|
||||
SERVER_STARTSTOP_MODULE = mod_import(settings.AT_SERVER_STARTSTOP_MODULE)
|
||||
|
||||
# module containing plugin services
|
||||
# modules containing plugin services
|
||||
SERVER_SERVICES_PLUGIN_MODULES = [mod_import(module) for module in make_iter(settings.SERVER_SERVICES_PLUGIN_MODULES)]
|
||||
WEB_PLUGINS_MODULE = mod_import(settings.WEB_PLUGINS_MODULE)
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Evennia Server settings
|
||||
|
|
@ -511,6 +512,11 @@ if WEBSERVER_ENABLED:
|
|||
web_root.putChild("media", static.File(settings.MEDIA_ROOT))
|
||||
# point our static resources to url /static
|
||||
web_root.putChild("static", static.File(settings.STATIC_ROOT))
|
||||
|
||||
if WEB_PLUGINS_MODULE:
|
||||
# custom overloads
|
||||
web_root = WEB_PLUGINS_MODULE.at_webserver_root_creation(web_root)
|
||||
|
||||
web_site = server.Site(web_root, logPath=settings.HTTP_LOG_FILE)
|
||||
|
||||
for proxyport, serverport in WEBSERVER_PORTS:
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ class EvenniaReverseProxyResource(ReverseProxyResource):
|
|||
# Website server resource
|
||||
#
|
||||
|
||||
|
||||
class DjangoWebRoot(resource.Resource):
|
||||
"""
|
||||
This creates a web root (/) that Django
|
||||
|
|
|
|||
|
|
@ -291,6 +291,8 @@ PORTAL_SERVICES_PLUGIN_MODULES = ["server.conf.portal_services_plugins"]
|
|||
# Module holding MSSP meta data. This is used by MUD-crawlers to determine
|
||||
# what type of game you are running, how many players you have etc.
|
||||
MSSP_META_MODULE = "server.conf.mssp"
|
||||
# Module for web plugins.
|
||||
WEB_PLUGINS_MODULE = "server.conf.web_plugins"
|
||||
# Tuple of modules implementing lock functions. All callable functions
|
||||
# inside these modules will be available as lock functions.
|
||||
LOCK_FUNC_MODULES = ("evennia.locks.lockfuncs", "server.conf.lockfuncs",)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue