Some minor edge-case fixes when using a session as caller.

This commit is contained in:
Griatch 2016-05-24 23:09:16 +02:00
parent f12c754225
commit df74380155
2 changed files with 8 additions and 5 deletions

View file

@ -434,15 +434,15 @@ class CmdOption(COMMAND_DEFAULT_CLASS):
if "save" in self.switches:
# save all options
self.player.db._saved_protocol_flags = flags
self.caller.db._saved_protocol_flags = flags
self.msg("{gSaved all options. Use @option/clear to remove.{n")
if "clear" in self.switches:
# clear all saves
self.player.db._saved_protocol_flags = {}
self.caller.db._saved_protocol_flags = {}
self.msg("{gCleared all saved options.")
options = dict(flags) # make a copy of the flag dict
saved_options = dict(self.player.attributes.get("_saved_protocol_flags", default={}))
saved_options = dict(self.caller.attributes.get("_saved_protocol_flags", default={}))
if "SCREENWIDTH" in options:
if len(options["SCREENWIDTH"]) == 1:

View file

@ -81,7 +81,7 @@ class NAttributeHandler(object):
"""
return key in self._store
def get(self, key):
def get(self, key, default=None):
"""
Get the named key value.
@ -92,7 +92,7 @@ class NAttributeHandler(object):
the value of the Nattribute.
"""
return self._store.get(key, None)
return self._store.get(key, default)
def add(self, key, value):
"""
@ -376,6 +376,9 @@ class ServerSession(Session):
for the protocol(s).
"""
# this can happen if this is triggered e.g. a command.msg
# that auto-adds the session, we'd get a kwarg collision.
kwargs.pop("session", None)
if text is not None:
self.data_out(text=text, **kwargs)
else: