Trap some more odd errors to assist in my tracking down their origin.

This commit is contained in:
Greg Taylor 2009-03-26 14:03:41 +00:00
parent 51edc17d59
commit 71a76cd1fb
3 changed files with 19 additions and 3 deletions

View file

@ -160,7 +160,14 @@ def match_exits(command):
"""
# If we're not logged in, don't check exits.
source_object = command.source_object
exits = source_object.get_location().get_contents(filter_type=defines_global.OTYPE_EXIT)
location = source_object.get_location()
if location == None:
logger.log_errmsg("cmdhandler.match_exits(): Object '%s' no location." %
source_object)
return
exits = location.get_contents(filter_type=defines_global.OTYPE_EXIT)
Object = ContentType.objects.get(app_label="objects",
model="object").model_class()
exit_matches = Object.objects.list_search_object_namestr(exits,

View file

@ -15,6 +15,7 @@ from src import scripthandler
from src import defines_global
from src import ansi
from src import session_mgr
from src import logger
# Import as the absolute path to avoid local variable clashes.
import src.flags
from src.util import functions_general
@ -225,7 +226,11 @@ class Object(models.Model):
"""
Returns the player object's account object (User object).
"""
return User.objects.get(id=self.id)
try:
return User.objects.get(id=self.id)
except User.DoesNotExist:
logger.log_errmsg("No account match for object id: %s" % self.id)
return None
def is_staff(self):
"""

View file

@ -107,7 +107,11 @@ class SessionProtocol(StatefulTelnetProtocol):
pobject = self.get_pobject()
if pobject:
pobject.set_flag("CONNECTED", False)
pobject.get_location().emit_to_contents("%s has disconnected." % (pobject.get_name(show_dbref=False),), exclude=pobject)
location = pobject.get_location()
if location != None:
location.emit_to_contents("%s has disconnected." % (pobject.get_name(show_dbref=False),), exclude=pobject)
uaccount = pobject.get_user_account()
uaccount.last_login = datetime.now()
uaccount.save()