summaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2015-04-28 19:28:15 +0300
committerAlon Levy <alon@pobox.com>2015-04-28 19:44:25 +0300
commitd5a6d1ca7fb948c466d686771e64e8f0883ffa3b (patch)
tree7c61e587be6047e1e1d01261e2b4b921f5e33057 /src/server
parent721c22391a8018d8c12a84ed123b0a99990a8164 (diff)
server/neo4j_cypher: avoid recursion
Could not reproduce locally but this was reported to fix a recursion happening easily by creating a document and cloning it. This avoids any recursion by punting to the enum equallity operator directly and once, mapping the other parameter optionally.
Diffstat (limited to 'src/server')
-rw-r--r--src/server/neo4j_cypher.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/server/neo4j_cypher.py b/src/server/neo4j_cypher.py
index 768d8668..6d1cfa57 100644
--- a/src/server/neo4j_cypher.py
+++ b/src/server/neo4j_cypher.py
@@ -35,10 +35,9 @@ class Query_Struct_Type(Enum):
assert False
def __eq__(self, other): # allow comparing against r/w/rw strings
- if other in ['r', 'w', 'rw']:
- if self == Query_Struct_Type.r and other == 'r': return True
- if self == Query_Struct_Type.w and other == 'w': return True
- if self == Query_Struct_Type.rw and other == 'rw': return True
+ mappings = {'r': Query_Struct_Type.r, 'w':Query_Struct_Type.w , 'rw':Query_Struct_Type.rw}
+ if other in mappings.keys():
+ other = mappings[other]
if not isinstance(other, Query_Struct_Type): return False
return super(Query_Struct_Type, self).__eq__(other)