diff --git a/docs/content.md b/docs/content.md index 5228dd2a..4b3e4acf 100644 --- a/docs/content.md +++ b/docs/content.md @@ -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). diff --git a/news/312.implementation b/news/312.implementation new file mode 100644 index 00000000..227d93ea --- /dev/null +++ b/news/312.implementation @@ -0,0 +1 @@ +Implemented unrestricted find. \ No newline at end of file diff --git a/src/plone/api/content.py b/src/plone/api/content.py index f85790ee..a3da980b 100644 --- a/src/plone/api/content.py +++ b/src/plone/api/content.py @@ -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) diff --git a/src/plone/api/tests/test_content.py b/src/plone/api/tests/test_content.py index 7123667c..7738a328 100644 --- a/src/plone/api/tests/test_content.py +++ b/src/plone/api/tests/test_content.py @@ -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"""