diff --git a/evennia/server/serversession.py b/evennia/server/serversession.py index 77a264baa9..33be5dd074 100644 --- a/evennia/server/serversession.py +++ b/evennia/server/serversession.py @@ -11,7 +11,7 @@ from django.utils import timezone from django.conf import settings from evennia.comms.models import ChannelDB from evennia.utils import logger -from evennia.utils.utils import make_iter, lazy_property +from evennia.utils.utils import make_iter, lazy_property, class_from_module from evennia.commands.cmdsethandler import CmdSetHandler from evennia.server.session import Session from evennia.scripts.monitorhandler import MONITOR_HANDLER @@ -25,13 +25,15 @@ _ANSI = None # i18n from django.utils.translation import gettext as _ +_BASE_SESSION_CLASS = class_from_module(settings.BASE_SESSION_CLASS) + # ------------------------------------------------------------- # Server Session # ------------------------------------------------------------- -class ServerSession(Session): +class ServerSession(_BASE_SESSION_CLASS): """ This class represents an account's session and is a template for individual protocols to communicate with Evennia. diff --git a/evennia/server/session.py b/evennia/server/session.py index ea5f0f8fe6..bc6dbe1990 100644 --- a/evennia/server/session.py +++ b/evennia/server/session.py @@ -12,7 +12,7 @@ import time # ------------------------------------------------------------ -class Session(object): +class Session: """ This class represents a player's session and is a template for both portal- and server-side sessions. diff --git a/evennia/server/sessionhandler.py b/evennia/server/sessionhandler.py index 39bf9ee9bd..122c65d4fb 100644 --- a/evennia/server/sessionhandler.py +++ b/evennia/server/sessionhandler.py @@ -18,7 +18,7 @@ from django.conf import settings from evennia.commands.cmdhandler import CMD_LOGINSTART from evennia.utils.logger import log_trace from evennia.utils.utils import ( - variable_from_module, + variable_from_module, class_from_module, is_iter, make_iter, delay, @@ -75,8 +75,7 @@ def delayed_import(): global _ServerSession, _AccountDB, _ServerConfig, _ScriptDB if not _ServerSession: # we allow optional arbitrary serversession class for overloading - modulename, classname = settings.SERVER_SESSION_CLASS.rsplit(".", 1) - _ServerSession = variable_from_module(modulename, classname) + _ServerSession = class_from_module(settings.SERVER_SESSION_CLASS) if not _AccountDB: from evennia.accounts.models import AccountDB as _AccountDB if not _ServerConfig: @@ -84,10 +83,10 @@ def delayed_import(): if not _ScriptDB: from evennia.scripts.models import ScriptDB as _ScriptDB # including once to avoid warnings in Python syntax checkers - assert _ServerSession - assert _AccountDB - assert _ServerConfig - assert _ScriptDB + assert _ServerSession, "ServerSession class could not load" + assert _AccountDB, "AccountDB class could not load" + assert _ServerConfig, "ServerConfig class could not load" + assert _ScriptDB, "ScriptDB class c ould not load" # ----------------------------------------------------------- diff --git a/evennia/utils/utils.py b/evennia/utils/utils.py index 45983efe19..2e5c8c789d 100644 --- a/evennia/utils/utils.py +++ b/evennia/utils/utils.py @@ -1411,7 +1411,7 @@ def fuzzy_import_from_module(path, variable, default=None, defaultpaths=None): def class_from_module(path, defaultpaths=None): """ - Return a class from a module, given the module's path. This is + Return a class from a module, given the class' full python path. This is primarily used to convert db_typeclass_path:s to classes. Args: