Moving a check for the connect channel, probably resolving a weird django error appearing in postgreSQL. Related to Issue 341.

This commit is contained in:
Griatch 2013-01-08 09:44:13 +01:00
parent f8514bb0f1
commit 45bf38679f

View file

@ -28,11 +28,6 @@ _DA = object.__delattr__
_CONNECT_CHANNEL = None _CONNECT_CHANNEL = None
try:
_CONNECT_CHANNEL = Channel.objects.filter(db_key=settings.CHANNEL_CONNECTINFO[0])[0]
except Exception, e:
print e
pass
# #
# Base class to inherit from. # Base class to inherit from.
@ -791,6 +786,13 @@ class Character(Object):
We stove away the character when logging off, otherwise the character object will We stove away the character when logging off, otherwise the character object will
remain in the room also after the player logged off ("headless", so to say). remain in the room also after the player logged off ("headless", so to say).
""" """
global _CONNECT_CHANNEL
if not _CONNECT_CHANNEL:
try:
_CONNECT_CHANNEL = Channel.objects.filter(db_key=settings.CHANNEL_CONNECTINFO[0])[0]
except Exception, e:
logger.log_trace()
if self.location: # have to check, in case of multiple connections closing if self.location: # have to check, in case of multiple connections closing
self.location.msg_contents("%s has left the game." % self.name, exclude=[self]) self.location.msg_contents("%s has left the game." % self.name, exclude=[self])
self.db.prelogout_location = self.location self.db.prelogout_location = self.location
@ -804,6 +806,12 @@ class Character(Object):
""" """
This recovers the character again after having been "stoved away" at disconnect. This recovers the character again after having been "stoved away" at disconnect.
""" """
global _CONNECT_CHANNEL
if not _CONNECT_CHANNEL:
try:
_CONNECT_CHANNEL = Channel.objects.filter(db_key=settings.CHANNEL_CONNECTINFO[0])[0]
except Exception, e:
logger.log_trace()
if self.db.prelogout_location: if self.db.prelogout_location:
# try to recover # try to recover
self.location = self.db.prelogout_location self.location = self.db.prelogout_location