Skip to content

Commit

Permalink
Lookup mapped catalogs for CatalogBrains (#54)
Browse files Browse the repository at this point in the history
* Lookup mapped catalogs for ZCBrain

* Changelog updated

* Do not override request parameter
  • Loading branch information
ramonski committed Mar 23, 2023
1 parent af2abd0 commit a594794
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
2.5.0 (unreleased)
------------------

- no changes yet
- #54 Lookup mapped catalogs for CatalogBrains


2.4.0 (2023-03-10)
Expand Down
6 changes: 5 additions & 1 deletion src/senaite/jsonapi/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Catalog(object):
interface.implements(ICatalog)

def __init__(self, context):
self.context = context
self._catalogs = {}

def search(self, query):
Expand All @@ -62,7 +63,10 @@ def __call__(self, query):
return self.search(query)

def get_catalog(self):
name = req.get("catalog", "portal_catalog")
name = req.get("catalog")
if not name:
catalogs = senaiteapi.get_catalogs_for(self.context)
name = catalogs[0].getId() if len(catalogs) > 0 else None
if name not in self._catalogs:
# Get the catalog directly from senaite api
cat = senaiteapi.get_tool(name)
Expand Down

0 comments on commit a594794

Please sign in to comment.