Skip to content

Commit

Permalink
Issue #97 i.e. allow for MultiPath Queries (#98)
Browse files Browse the repository at this point in the history
Changes for bugfix #97 - making PATH_INDICES dynamic
  • Loading branch information
gogobd authored Jul 14, 2020
1 parent 41a906f commit 6ba125e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/97.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixing issue #97: Multiple path support for Translation Groups, using PATH_INDICES as suggested by jensens
12 changes: 10 additions & 2 deletions plone/app/querystring/queryparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


Row = namedtuple('Row', ['index', 'operator', 'values'])
PATH_INDICES = {'path'}


def parseFormquery(context, formquery, sort_on=None, sort_order=None):
Expand Down Expand Up @@ -41,8 +42,15 @@ def parseFormquery(context, formquery, sort_on=None, sort_order=None):
kwargs = parser(context, row)

# Special path handling - since multipath queries are possible
if 'path' in query and 'path' in kwargs:
query['path']['query'].extend(kwargs['path']['query'])
path_index = PATH_INDICES & set(kwargs)
if len(path_index) == 1:
path_index = list(path_index)[0]
if path_index in query:
query[path_index]['query'].extend(kwargs[path_index]['query'])
else:
query.update(kwargs)
elif len(path_index) > 1:
raise IndexError("Too many path indices in one row.")
else:
query.update(kwargs)

Expand Down

0 comments on commit 6ba125e

Please sign in to comment.