Structure handlers to allow .get() to return lists
See #1154. In the end I didn't modify the Attributehandler and TagHandler like this, instead I added the `return_list` argument for cases when one wants a guaranteed return.
This commit is contained in:
parent
05a3d0435d
commit
92df3ce5ae
13 changed files with 86 additions and 1608 deletions
|
|
@ -93,6 +93,7 @@ class MonitorHandler(object):
|
|||
def at_update(self, obj, fieldname):
|
||||
"""
|
||||
Called by the field as it saves.
|
||||
|
||||
"""
|
||||
to_delete = []
|
||||
if obj in self.monitors and fieldname in self.monitors[obj]:
|
||||
|
|
@ -175,6 +176,9 @@ class MonitorHandler(object):
|
|||
"""
|
||||
List all monitors.
|
||||
|
||||
Returns:
|
||||
monitors (list): The handled monitors.
|
||||
|
||||
"""
|
||||
output = []
|
||||
for obj in self.monitors:
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ class ScriptHandler(object):
|
|||
scripts (list): The found scripts matching `key`.
|
||||
|
||||
"""
|
||||
return ScriptDB.objects.get_all_scripts_on_obj(self.obj, key=key)
|
||||
return list(ScriptDB.objects.get_all_scripts_on_obj(self.obj, key=key))
|
||||
|
||||
def delete(self, key=None):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from datetime import datetime, timedelta
|
|||
|
||||
from twisted.internet import reactor, task
|
||||
from evennia.server.models import ServerConfig
|
||||
from evennia.utils.logger import log_trace, log_err
|
||||
from evennia.utils.logger import log_err
|
||||
from evennia.utils.dbserialize import dbserialize, dbunserialize
|
||||
|
||||
TASK_HANDLER = None
|
||||
|
|
@ -113,9 +113,9 @@ class TaskHandler(object):
|
|||
try:
|
||||
dbserialize(arg)
|
||||
except (TypeError, AttributeError):
|
||||
logger.log_err("The positional argument {} cannot be "
|
||||
"pickled and will not be present in the arguments "
|
||||
"fed to the callback {}".format(arg, callback))
|
||||
log_err("The positional argument {} cannot be "
|
||||
"pickled and will not be present in the arguments "
|
||||
"fed to the callback {}".format(arg, callback))
|
||||
else:
|
||||
safe_args.append(arg)
|
||||
|
||||
|
|
@ -123,9 +123,9 @@ class TaskHandler(object):
|
|||
try:
|
||||
dbserialize(value)
|
||||
except (TypeError, AttributeError):
|
||||
logger.log_err("The {} keyword argument {} cannot be "
|
||||
"pickled and will not be present in the arguments "
|
||||
"fed to the callback {}".format(key, value, callback))
|
||||
log_err("The {} keyword argument {} cannot be "
|
||||
"pickled and will not be present in the arguments "
|
||||
"fed to the callback {}".format(key, value, callback))
|
||||
else:
|
||||
safe_kwargs[key] = value
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue