From abce844360ec05e1c555717f954c48f575f479b9 Mon Sep 17 00:00:00 2001 From: joe <joe@autistici.org> Date: Sun, 1 Dec 2013 11:12:03 +0100 Subject: [PATCH] Changed the encode/decode of master keys to handle how etcd works. Also fixed a typo in calling write() with a parameter. --- configdb/db/interface/etcd_interface.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/configdb/db/interface/etcd_interface.py b/configdb/db/interface/etcd_interface.py index 6d3e670..b133c99 100644 --- a/configdb/db/interface/etcd_interface.py +++ b/configdb/db/interface/etcd_interface.py @@ -22,11 +22,10 @@ class EtcdSession(inmemory_interface.InMemorySession): self.db = db def _escape(self,s): - # Hack alert! Since etcd interprets any '/' as a dir separator, - # we simply replace it with a double backslash in the path. - # this of course introduces a potential bug. - s = s.replace('/','\\\\') - return urllib.quote(s, safe='') + return s.encode('hex') + + def _unescape(self, s): + return s.decode('hex') def _mkpath(self, entity_name, obj_name=None): path = os.path.join(self.db.root, self._escape(entity_name)) @@ -188,7 +187,7 @@ class EtcdInterface(base.DbInterface): } self.conn.write(path, json.dumps(audit)) try: - self.conn.write(path, json.dumps(audit), prevExist=False) + self.conn.write(path, json.dumps(audit)) except ValueError: pass -- GitLab