Some command bugfixes. Added some more debug messages for pinning down issue101.

This commit is contained in:
Griatch 2010-09-19 06:57:08 +00:00
parent 27b7570aab
commit 164eb5b89b
5 changed files with 89 additions and 69 deletions

View file

@ -77,7 +77,7 @@ def import_cmdset(python_path, cmdsetobj, emit_to_obj=None, no_logging=False):
instance from a python module, given a python_path. It's usually accessed
through the cmdsethandler's add() and add_default() methods.
python_path - This is the full path to the cmdset object.
cmsetobj - the database object/typeclass on which this cmdset is to be assigned
cmdsetobj - the database object/typeclass on which this cmdset is to be assigned
(this can be also channels and exits, as well as players but there will
always be such an object)
emit_to_obj - if given, error is emitted to this object (in addition to logging)
@ -88,17 +88,18 @@ def import_cmdset(python_path, cmdsetobj, emit_to_obj=None, no_logging=False):
try:
try:
print "importing %s: CACHED_CMDSETS=%s" % (python_path, CACHED_CMDSETS)
wanted_cache_key = python_path
cmdsetclass = CACHED_CMDSETS.get(wanted_cache_key, None)
errstring = ""
if not cmdsetclass:
#print "cmdset %s not in cache. Reloading." % wanted_cache_key
print "cmdset %s not in cache. Reloading." % wanted_cache_key
# Not in cache. Reload from disk.
modulepath, classname = python_path.rsplit('.', 1)
module = __import__(modulepath, fromlist=[True])
cmdsetclass = module.__dict__[classname]
CACHED_CMDSETS[wanted_cache_key] = cmdsetclass
#print "cmdset %s found." % wanted_cache_key
print "cmdset %s found." % wanted_cache_key
#instantiate the cmdset (and catch its errors)
if callable(cmdsetclass):
cmdsetclass = cmdsetclass(cmdsetobj)
@ -118,6 +119,7 @@ def import_cmdset(python_path, cmdsetobj, emit_to_obj=None, no_logging=False):
raise
except Exception:
if errstring and not no_logging:
print errstring
logger.log_trace()
if emit_to_obj:
emit_to_obj.msg(errstring)

View file

@ -227,12 +227,13 @@ class CheckSessions(Script):
"Setup the script"
self.key = "sys_session_check"
self.desc = "Checks sessions so they are live."
self.interval = 60 # repeat every 60 seconds
self.interval = 60 # repeat every 60 seconds
self.persistent = True
def at_repeat(self):
"called every 60 seconds"
#print "session check!"
#print "ValidateSessions run"
sessionhandler.check_all_sessions()
class ValidateScripts(Script):
@ -246,6 +247,7 @@ class ValidateScripts(Script):
def at_repeat(self):
"called every hour"
print "ValidateScripts run."
ScriptDB.objects.validate()
class ValidateChannelHandler(Script):
@ -260,6 +262,7 @@ class ValidateChannelHandler(Script):
def at_repeat(self):
"called every hour+"
print "ValidateChannelHandler run."
channelhandler.CHANNELHANDLER.update()
class AddCmdSet(Script):
@ -306,6 +309,8 @@ class AddCmdSet(Script):
This removes the cmdset when the script stops
"""
cmdset = self.db.cmdset
print "AddCmdSets: at_stop() for %s called." % self.obj
if cmdset:
if self.db.add_default:
self.obj.cmdset.delete_default()

View file

@ -480,7 +480,7 @@ class TypedObject(SharedMemoryModel):
attribute_model_name = "Attribute"
def __eq__(self, other):
return other and self.id == other.id
return other and hasattr(other, 'id') and self.id == other.id
def __str__(self):
return smart_str("%s" % self.key)