Optimize _Saverdict.update that caused issues for webclient option update (#2224)

This commit is contained in:
Griatch 2020-11-01 11:19:14 +01:00
parent 668551a0d5
commit 91e2e68291
5 changed files with 10 additions and 5 deletions

View file

@ -389,7 +389,7 @@ gaming style you like and possibly any new ones you can come up with!
(aka MUDs, MUSHes, MUX, MOOs...). It is open-source and |wfree to use|n, also for (aka MUDs, MUSHes, MUX, MOOs...). It is open-source and |wfree to use|n, also for
commercial projects (BSD license). commercial projects (BSD license).
Out of the box, Evennia provides a |wfull, if empty game|n. Whereas you can play Out of the box, Evennia provides a |wworking, if empty game|n. Whereas you can play
via traditional telnet MUD-clients, the server runs your game's website and via traditional telnet MUD-clients, the server runs your game's website and
offers a |wHTML5 webclient|n so that people can play your game in their browser offers a |wHTML5 webclient|n so that people can play your game in their browser
without downloading anything extra. without downloading anything extra.

View file

@ -93,7 +93,7 @@ class MonitorHandler(object):
def at_update(self, obj, fieldname): def at_update(self, obj, fieldname):
""" """
Called by the field as it saves. Called by the field/attribute as it saves.
""" """
to_delete = [] to_delete = []

View file

@ -521,9 +521,8 @@ def webclient_options(session, *args, **kwargs):
session=session, session=session,
) )
else: else:
# kwargs provided: persist them to the account object # kwargs provided: persist them to the account object.
for key, value in kwargs.items(): clientoptions.update(kwargs)
clientoptions[key] = value
# OOB protocol-specific aliases and wrappers # OOB protocol-specific aliases and wrappers

View file

@ -300,6 +300,10 @@ class _SaverDict(_SaverMutable, MutableMapping):
def has_key(self, key): def has_key(self, key):
return key in self._data return key in self._data
@_save
def update(self, *args, **kwargs):
self._data.update(*args, **kwargs)
class _SaverSet(_SaverMutable, MutableSet): class _SaverSet(_SaverMutable, MutableSet):
""" """

View file

@ -268,12 +268,14 @@ An "emitter" object must have a function
// Parse the incoming data, send to emitter // Parse the incoming data, send to emitter
// Incoming data is on the form [cmdname, args, kwargs] // Incoming data is on the form [cmdname, args, kwargs]
data = JSON.parse(data); data = JSON.parse(data);
// console.log(" server->client:", data)
Evennia.emit(data[0], data[1], data[2]); Evennia.emit(data[0], data[1], data[2]);
}; };
} }
var msg = function(data) { var msg = function(data) {
// send data across the wire. Make sure to json it. // send data across the wire. Make sure to json it.
// console.log("client->server:", data)
websocket.send(JSON.stringify(data)); websocket.send(JSON.stringify(data));
}; };