Skip to content

Commit

Permalink
Fix search catalog for metadata lookup (#57)
Browse files Browse the repository at this point in the history
* Fix mapped catalog for metadata lookup

* Changelog updated
  • Loading branch information
ramonski committed Apr 2, 2023
1 parent a352b3a commit d8b9cb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
2.5.0 (unreleased)
------------------

- #57 Fix search catalog for metadata lookup
- #56 Fix implicit imports for controlpanel mappings
- #54 Lookup mapped catalogs for CatalogBrains

Expand Down
7 changes: 4 additions & 3 deletions src/senaite/jsonapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,12 +660,13 @@ def get_brain(brain_or_object):

# fetch the brain by UID
uid = get_uid(brain_or_object)
uc = get_tool("uid_catalog")
results = uc({"UID": uid}) or search(query={'UID': uid})
portal_type = api.get_portal_type(brain_or_object)
query = {"UID": uid, "portal_type": portal_type}
results = api.search(query)
if len(results) == 0:
return None
if len(results) > 1:
fail(500, "More than one object with UID={} found in portal_catalog".format(uid))
fail(500, "More than one object with UID={}".format(uid))
return results[0]


Expand Down

0 comments on commit d8b9cb3

Please sign in to comment.