Moved import of SESSIONS to avoid a circular import situation under i18n.

This commit is contained in:
Griatch 2013-02-10 11:52:31 +01:00
parent 390bdd28a7
commit 433cb5b9c0
2 changed files with 10 additions and 4 deletions

View file

@ -47,7 +47,6 @@ from django.utils.encoding import smart_str
from src.server.caches import get_field_cache, set_field_cache, del_field_cache
from src.server.caches import get_prop_cache, set_prop_cache, del_prop_cache
from src.server.sessionhandler import SESSIONS
from src.players import manager
from src.typeclasses.models import Attribute, TypedObject, TypeNick, TypeNickHandler
from src.typeclasses.typeclass import TypeClass
@ -58,6 +57,7 @@ from src.utils.utils import inherits_from
__all__ = ("PlayerAttribute", "PlayerNick", "PlayerDB")
_SESSIONS = None
_AT_SEARCH_RESULT = utils.variable_from_module(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
_GA = object.__getattribute__
@ -333,7 +333,10 @@ class PlayerDB(TypedObject):
#@property
def sessions_get(self):
"Getter. Retrieve sessions related to this player/user"
return SESSIONS.sessions_from_player(self)
global _SESSIONS
if not _SESSIONS:
from src.server.sessionhandler import SESSIONS as _SESSIONS
return _SESSIONS.sessions_from_player(self)
#@sessions.setter
def sessions_set(self, value):
"Setter. Protects the sessions property from adding things"

View file

@ -12,7 +12,6 @@ from twisted.internet.defer import maybeDeferred
from twisted.internet.task import LoopingCall
from django.conf import settings
from src.server import caches
from src.server.sessionhandler import SESSIONS
from src.typeclasses.typeclass import TypeClass
from src.scripts.models import ScriptDB
from src.comms import channelhandler
@ -23,6 +22,7 @@ __all__ = ["Script", "DoNothing", "CheckSessions", "ValidateScripts", "ValidateC
if not is_pypy:
__all__.append("ClearAttributeCache")
_SESSIONS = None
_ATTRIBUTE_CACHE_MAXSIZE = settings.ATTRIBUTE_CACHE_MAXSIZE # attr-cache size in MB.
#
@ -416,9 +416,12 @@ class CheckSessions(Script):
def at_repeat(self):
"called every 60 seconds"
global _SESSIONS
if not _SESSIONS:
from src.server.sessionhandler import SESSIONS as _SESSIONS
#print "session check!"
#print "ValidateSessions run"
SESSIONS.validate_sessions()
_SESSIONS.validate_sessions()
class ValidateScripts(Script):
"Check script validation regularly"