Skip to content

Commit

Permalink
Merge pull request #360 from plone/remove-superfluous-path-injection
Browse files Browse the repository at this point in the history
remove dup path injection code in collections results method
  • Loading branch information
agitator committed Jul 20, 2016
2 parents 7b29a8e + 264dbb8 commit c076909
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Expand Up @@ -18,6 +18,12 @@ New features:

Bug fixes:

- Remove ``path`` index injection in "plone.collection" behaviors ``results`` method.
It is a duplicate.
Exactly the same is done already in the ``plone.app.querybuilder.querybuilder._makequery``,
which is called by above ``results`` method.
[jensens]

- Select all migratable types in migration-form by default. Fixes #193.
[pbauer]

Expand Down
29 changes: 1 addition & 28 deletions plone/app/contenttypes/behaviors/collection.py
Expand Up @@ -115,35 +115,8 @@ def results(self, batch=True, b_start=0, b_size=None,
sort_on = self.sort_on
if not limit:
limit = self.limit

query = self.query

# Handle INavigationRoot awareness as follows:
# - If query is None or empty then do nothing.
# - If query already contains a criteria for the index "path", then do
# nothing, since plone.app.querybuilder takes care of this
# already. (See the code of _path and _relativePath inside
# p.a.querystring.queryparser to understand).
# - If query does not contain any criteria using the index "path", then
# add a criteria to match everything under the path "/" (which will
# be converted to the actual navigation root path by
# p.a.querystring).
if query:
has_path_criteria = any(
(criteria['i'] == 'path')
for criteria in query
)
if not has_path_criteria:
# Make a copy of the query to avoid modifying it
query = list(self.query)
query.append({
'i': 'path',
'o': 'plone.app.querystring.operation.string.path',
'v': '/',
})

return querybuilder(
query=query, batch=batch, b_start=b_start, b_size=b_size,
query=self.query, batch=batch, b_start=b_start, b_size=b_size,
sort_on=sort_on, sort_order=sort_order,
limit=limit, brains=brains, custom_query=custom_query
)
Expand Down

0 comments on commit c076909

Please sign in to comment.