Moving some of the login tasks out of sessions.py and into the BasicPlayer script parent. Also, added seconds to the 'time' command, which I apparently forgot.

This commit is contained in:
Greg Taylor 2008-06-15 21:29:27 +00:00
parent b12ba45cc7
commit cf18029be1
7 changed files with 69 additions and 23 deletions

View file

@ -135,6 +135,15 @@ class Object(models.Model):
"""
BEGIN COMMON METHODS
"""
def get_session(self):
"""
Returns the session object for a player, or None if none exists.
"""
if self.is_player():
return session_mgr.session_from_object(self)
else:
return None
def emit_to(self, message):
"""
Emits something to any sessions attached to the object.
@ -636,7 +645,11 @@ class Object(models.Model):
Returns an object's script parent.
"""
if not self.scriptlink:
self.scriptlink = scripthandler.scriptlink(self, self.get_attribute_value('__parent', 'basicobject'))
if self.is_player():
script_to_load = 'player/basicplayer'
else:
script_to_load = 'basicobject'
self.scriptlink = scripthandler.scriptlink(self, self.get_attribute_value('__parent', script_to_load))
if self.scriptlink:
# If the scriptlink variable can't be populated, this will fail