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

Fix KeyError if registry key not found #2361

Merged
merged 3 commits into from
Aug 19, 2023
Merged
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
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
2.5.0 (unreleased)
------------------

- #2361 Fix KeyError if registry key not found
- #2358 Add confirmation when unlinking reference
- #2357 Skip object reindexing when global auditlog is disabled
- #2354 Render all legacy resources at the end of the page
Expand Down
9 changes: 5 additions & 4 deletions src/senaite/core/registry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
# Some rights reserved, see README and LICENSE.

from plone.registry.interfaces import IRegistry
from senaite.core import logger
from senaite.core.registry.schema import ISenaiteRegistry
from zope.component import getUtility
from zope.schema._bootstrapinterfaces import WrongType
from zope.dottedname.resolve import resolve
from zope.schema._bootstrapinterfaces import WrongType


def get_registry():
Expand Down Expand Up @@ -62,11 +63,11 @@ def get_registry_record(name, default=None):
"""
registry = get_registry()
for interface in get_registry_interfaces():
proxy = registry.forInterface(interface)
try:
proxy = registry.forInterface(interface)
return getattr(proxy, name)
except AttributeError:
pass
except (AttributeError, KeyError) as exc:
logger.error(exc)
return default


Expand Down