Changed how lazy-loading of handlers work, using a werkzeug recipe. Much more efficient now.

This commit is contained in:
Griatch 2014-07-06 13:10:03 +02:00
parent 680e603c4d
commit e6950aadf2
10 changed files with 125 additions and 144 deletions

View file

@ -13,8 +13,9 @@ from django.conf import settings
#from src.scripts.models import ScriptDB
from src.comms.models import ChannelDB
from src.utils import logger, utils
from src.utils.utils import make_iter, to_unicode, LazyLoadHandler
from src.commands import cmdhandler, cmdsethandler
from src.utils.utils import make_iter, to_unicode
from src.commands.cmdhandler import cmdhandler
from src.commands.cmdsethandler import CmdSetHandler
from src.server.session import Session
IDLE_COMMAND = settings.IDLE_COMMAND
@ -49,7 +50,7 @@ class ServerSession(Session):
self.puppet = None
self.player = None
self.cmdset_storage_string = ""
self.cmdset = LazyLoadHandler(self, "cmdset", cmdsethandler.CmdSetHandler, True)
self.cmdset = CmdSetHandler(self, True)
def __cmdset_storage_get(self):
return [path.strip() for path in self.cmdset_storage_string.split(',')]
@ -103,7 +104,7 @@ class ServerSession(Session):
self.player.save()
# add the session-level cmdset
self.cmdset = LazyLoadHandler(self, "cmdset", cmdsethandler.CmdSetHandler, True)
self.cmdset = CmdSetHandler(self, True)
def at_disconnect(self):
"""
@ -198,7 +199,7 @@ class ServerSession(Session):
else:
text = self.player.nicks.nickreplace(text,
categories=("inputline", "channels"), include_player=False)
cmdhandler.cmdhandler(self, text, callertype="session", sessid=self.sessid)
cmdhandler(self, text, callertype="session", sessid=self.sessid)
self.update_session_counters()
if "oob" in kwargs:
# handle oob instructions