csocket multi-set fix: prevent to convert `list`, `dict`, `set` during transfer (send), this offers a sending of 'multi-set' arrays

(missed by cherry-picking from multi-set branch)
pull/1422/head
sebres 2016-05-13 22:16:35 +02:00
parent e0924e0d1b
commit cb280b817f
3 changed files with 9 additions and 2 deletions

View File

@ -44,7 +44,9 @@ class CSocket:
def send(self, msg):
# Convert every list member to string
obj = dumps([str(m) for m in msg], HIGHEST_PROTOCOL)
obj = dumps(map(
lambda m: str(m) if not isinstance(m, (list, dict, set)) else m, msg),
HIGHEST_PROTOCOL)
self.__csock.send(obj + CSPROTO.END)
return self.receive(self.__csock)

View File

@ -266,8 +266,10 @@ class Server:
flt = self.__jails[name].filter
if multiple:
for value in value:
logSys.debug(" failregex: %r", value)
flt.addFailRegex(value)
else:
logSys.debug(" failregex: %r", value)
flt.addFailRegex(value)
def delFailRegex(self, name, index):
@ -280,8 +282,10 @@ class Server:
flt = self.__jails[name].filter
if multiple:
for value in value:
logSys.debug(" ignoreregex: %r", value)
flt.addIgnoreRegex(value)
else:
logSys.debug(" ignoreregex: %r", value)
flt.addIgnoreRegex(value)
def delIgnoreRegex(self, name, index):

View File

@ -52,7 +52,7 @@ class Transmitter:
def proceed(self, command):
# Deserialize object
logSys.debug("Command: " + repr(command))
logSys.debug("Command: %r", command)
try:
ret = self.__commandHandler(command)
ack = 0, ret
@ -263,6 +263,7 @@ class Transmitter:
action = self.__server.getAction(name, actionname)
if multiple:
for cmd in command[3]:
logSys.debug(" %r", cmd)
actionkey = cmd[0]
if callable(getattr(action, actionkey, None)):
actionvalue = json.loads(cmd[1]) if len(cmd)>1 else {}