Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I implemented unrestricted find #521

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,21 @@ documents = api.content.find(
%
% self.assertGreater(len(documents), 0)

Find all Documents, and use unrestrictedSearchResults:

```python
from plone import api
documents = api.content.find(
context=api.portal.get(),
portal_type='Document',
unrestricted=True,
)
```

% invisible-code-block: python
%
% self.assertGreater(len(documents), 0)

More information about how to use the catalog may be found in the
[Plone Documentation](https://5.docs.plone.org/develop/plone/searching_and_indexing/index.html).

Expand Down
1 change: 1 addition & 0 deletions news/312.implementation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Implemented unrestricted find.
5 changes: 4 additions & 1 deletion src/plone/api/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,4 +652,7 @@ def find(context=None, depth=None, **kwargs):
if not valid_indexes:
return []

return catalog(**query)
if kwargs.get("unrestricted"):
return catalog.unrestrictedSearchResults(**query)
else:
return catalog(**query)
7 changes: 7 additions & 0 deletions src/plone/api/tests/test_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,13 @@ def test_find(self):
documents = api.content.find(portal_type="Document")
self.assertEqual(len(documents), 2)

def test_find(self):
"""Test the finding of content in various ways."""

# Find documents
documents = api.content.find(portal_type="Document", unrestricted=True)
self.assertEqual(len(documents), 2)

def test_find_empty_query(self):
"""Make sure an empty query yields no results"""

Expand Down