Skip to content

get_registry_record errors even if default value is given #417

@fredvd

Description

@fredvd

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:

if interface is not None:
records = registry.forInterface(interface)
_marker = object()
if getattr(records, name, _marker) != _marker:
return registry['{0}.{1}'.format(interface.__identifier__, name)]
if default is not MISSING:
return default

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.'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions