From 45bf38679fdf13957e9050fb44b8c196cc1fe905 Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 8 Jan 2013 09:44:13 +0100 Subject: [PATCH] Moving a check for the connect channel, probably resolving a weird django error appearing in postgreSQL. Related to Issue 341. --- src/objects/objects.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/objects/objects.py b/src/objects/objects.py index b28d0e5481..4590aea574 100644 --- a/src/objects/objects.py +++ b/src/objects/objects.py @@ -28,11 +28,6 @@ _DA = object.__delattr__ _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. @@ -791,6 +786,13 @@ class Character(Object): 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). """ + 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 self.location.msg_contents("%s has left the game." % self.name, exclude=[self]) 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. """ + 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: # try to recover self.location = self.db.prelogout_location