From 9bf68c1639897639bfcf31e7de4f072f1723a90f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 1 Mar 2014 10:48:08 -0500 Subject: [PATCH] Fix expression detection with unicode strings If data was coming in as unicode strings (as is the case in the json parser), it failed to treat the data as equivalent to string. Correct by checking both str and unicode for now --- BUGS | 21 +++++++++++++++++++++ confluent/messages.py | 6 +++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/BUGS b/BUGS index 24851964..1922ba0d 100644 --- a/BUGS +++ b/BUGS @@ -2,3 +2,24 @@ -Setting multiple values at once where one is an expression including the othe can fail because the expression is attempted to set before the next setting comes to work and then we get a stack trace + Should leave value out of it and set 'broken' with a reason as the + value to the key +-cannot set expression value through confetty +-expressionkeys never gets smaller - perf impact +-need event notification for config change- e.g. set attribute triggers consol + session object check to see if credentials changed +-When the time comes to dole out configuration/discovery, take page from xCAT + 'flexdiscover' command, if possible bring an ipmi device under management + by way of ipv6 to eliminate requirement for ip to be specified. + Requires the polling event support (which is required for security anyway) + +-this stack trace (happened with method was set to ""): +Traceback (most recent call last): + File "/usr/lib/python2.6/site-packages/eventlet/wsgi.py", line 402, in handle_one_response + for data in result: + File "/home/jbjohnso/Development/confluent/confluent/httpapi.py", line 301, in resourcehandler + cfgmgr, querydict) + File "/home/jbjohnso/Development/confluent/confluent/pluginapi.py", line 273, in handle_path + passvalue = pluginmap[plugpath].__dict__[operation]( +KeyError: '' + diff --git a/confluent/messages.py b/confluent/messages.py index 65334247..2fe53f05 100644 --- a/confluent/messages.py +++ b/confluent/messages.py @@ -164,7 +164,7 @@ class InputAttributes(ConfluentMessage): if nodes is None: self.attribs = inputdata for attrib in self.attribs: - if (type(self.attribs[attrib]) == str and + if (type(self.attribs[attrib]) in (str, unicode) and '{' in self.attribs[attrib]): self.attribs[attrib] = {'expression': self.attribs[attrib]} return @@ -185,7 +185,7 @@ class InputAttributes(ConfluentMessage): return {} nodeattr = self.nodeattribs[node] for attr in nodeattr: - if type(nodeattr[attr]) == str and '{' in nodeattr[attr]: + if type(nodeattr[attr]) in (str, unicode) and '{' in nodeattr[attr]: nodeattr[attr] = {'expression': nodeattr[attr]} return nodeattr @@ -290,7 +290,7 @@ class Attributes(ConfluentMessage): self.desc = desc nkv = {} for key in kv.iterkeys(): - if type(kv[key]) == str: + if type(kv[key]) in (str, unicode): nkv[key] = {'value': kv[key]} else: nkv[key] = kv[key]