plone / plone/plone.api

get_registry_record errors even if default value is given

Open
#417 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
101
Forks
62
Avg merge
15h 15m
Merged PRs (30d)
1

Description

expected behavior:

When I query a record that is not yet loaded in the registry by running an upgrade step which reads in registry records defined by xml or a zope.schema interface, I should receive a default parameter if I passed that into the get_registry_record function call

What happens:

https://github.com/plone/plone.api/blob/a8361ed4f24df027cd3afae68a30454ad5b299e1/src/plone/api/portal.py#L299-L306

The function already errors on L300 when the forInterface() call cannot find my schema, L305 is never reached in this case.

  Module plone.api.portal, line 2, in get_registry_record
  Module plone.api.validation, line 77, in wrapped
  Module plone.api.portal, line 300, in get_registry_record
  Module plone.registry.registry, line 78, in forInterface
KeyError: 'Interface `myproject.content.interfaces.IProjectSettings` defines a field `somefield`, for which there is no record.'

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/plone/api/portal.py at lines 299-306 and inspect get_registry_record, then reproduce the case where a schema-defined registry record is missing while a default is supplied. Done means the supplied default is returned instead of the KeyError shown in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.