From d5a6d1ca7fb948c466d686771e64e8f0883ffa3b Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Tue, 28 Apr 2015 19:28:15 +0300 Subject: 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. --- src/server/neo4j_cypher.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/server') 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) -- cgit v1.3.1