Skip to content

Commit

Permalink
Move test or options to 'set' method
Browse files Browse the repository at this point in the history
  • Loading branch information
andbag committed Apr 9, 2019
1 parent 5b0dac8 commit 71adae1
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/Products/ZCatalog/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self, request, iid, options=(), operators=('or', 'and'),
self.id = iid
self.operators = operators
self.operator = default_operator
self.options = options

if iid not in request:
self.keys = None
Expand All @@ -76,11 +77,7 @@ def __init__(self, request, iid, options=(), operators=('or', 'and'),
if op == 'query':
continue

if op in options:
self.set(op, param[op])
else:
raise ValueError(('index {0!r}: option {1!r}'
' is not valid').format(iid, op))
self.set(op, param[op])

else:
# query is tuple, list, string, number, or something else
Expand All @@ -92,11 +89,8 @@ def __init__(self, request, iid, options=(), operators=('or', 'and'),
for field in request.keys():
if field.startswith(iid + '_'):
iid_tmp, op = field.split('_')
if op in options:
self.set(op, request[field])
else:
raise ValueError(('index {0!r}: option {1!r}'
' is not valid').format(iid, op))

self.set(op, request[field])

self.keys = keys
not_value = getattr(self, 'not', None)
Expand Down Expand Up @@ -125,4 +119,8 @@ def get(self, key, default_v=None):
return default_v

def set(self, key, value):
setattr(self, key, value)
if key in self.options:
setattr(self, key, value)
else:
raise ValueError(('index {0!r}: option {1!r}'
' is not valid').format(self.id, key))

0 comments on commit 71adae1

Please sign in to comment.