You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Like this, the created record in the registry has a field knows about
the interface (due to the interface="..."). If a field knows about the interface the record will provide IInterfaceAwareRecord on
initialization.
In version 1.2.0 the record declaration was changed to:
In here we do not define the interface anymore but do define the field
itself.
Now when you have initially installed version 1.1.0 or 1.1.1 the field
knows the interface. When you reinstall the profile with version 1.2.0
and above plone.app.registry will get the existing record from the
registry. At that moment it sees that its field knows about the
interface and thus provides the IInterfaceAwareRecord interface. During
the registration of the entry, it finds that we declare the field
manually in the XML. Because of that, it creates a new field in case
something has changed. During this creation process of the field, it lets
the field know about the interface. BUT because we didn't define an
interface this time in the record (interface="...") it sets None
instead of our actual interface.
Now during the rest of the installation process, the record provides
IInterfaceAwareRecord even though the field does not know about the
interface anymore.
Later on, in the record registration process, this will trigger the redispatchInterfaceAwareRecordEvents subscriber from plone.registry.
At that moment it thinks, the record knows about the interface because it
still provides IInterfaceAwareRecord. This causes a failure when trying
to resolve that interface.
Expected behaviour
According to the plone.app.registrys docs<record name="ftw.datepicker.interfaces.IDatetimeRegistry.formats"> and <record interface="ftw.datepicker.interfaces.IDatetimeRegistry" field="formats"> are equivalent so it should fail when using one method once and the other another time.
iffieldisnotNoneandnotIFieldRef.providedBy(field):
# Set interface name and fieldName, if applicablefield.interfaceName=interfaceNamefield.fieldName=fieldNameifinterfaceNameisNoneandexisting_record:
# Remove interface awareness in case the previous field was interface awarenoLongerProvides(existing_record, IInterfaceAwareRecord)
Or we set the old interfaceName to the new field like so:
iffieldisnotNoneandnotIFieldRef.providedBy(field):
# Set interface name and fieldName, if applicablefield.interfaceName=existing_record.field.interfaceNameifexisting_recordelseinterfaceNamefield.fieldName=fieldName
In the second solution, the fieldName could also be reused from the old field if possible.
The text was updated successfully, but these errors were encountered:
Tested with
Plone=5.1.6
withplone.app.registry=1.7.5
andplone.registry=1.1.5
Problem
In the release 1.1.0 and 1.1.1 ftw.datepicker added registry entries as
follows:
Like this, the created record in the registry has a field knows about
the interface (due to the
interface="..."
). If a field knows about theinterface
the record will provide IInterfaceAwareRecord oninitialization.
In version 1.2.0 the record declaration was changed to:
In here we do not define the interface anymore but do define the field
itself.
Now when you have initially installed version 1.1.0 or 1.1.1 the field
knows the interface. When you reinstall the profile with version 1.2.0
and above
plone.app.registry
will get the existing record from theregistry. At that moment it sees that its field knows about the
interface and thus provides the
IInterfaceAwareRecord
interface. Duringthe registration of the entry, it finds that we declare the
field
manually in the XML. Because of that, it creates a new field in case
something has changed. During this creation process of the field, it lets
the field know about the interface. BUT because we didn't define an
interface this time in the record (
interface="..."
) it setsNone
instead of our actual interface.
Now during the rest of the installation process, the record provides
IInterfaceAwareRecord even though the field does not know about the
interface anymore.
Later on, in the record registration process, this will trigger the
redispatchInterfaceAwareRecordEvents
subscriber fromplone.registry
.At that moment it thinks, the record knows about the interface because it
still provides IInterfaceAwareRecord. This causes a failure when trying
to resolve that interface.
Expected behaviour
According to the
plone.app.registry
s docs<record name="ftw.datepicker.interfaces.IDatetimeRegistry.formats">
and<record interface="ftw.datepicker.interfaces.IDatetimeRegistry" field="formats">
are equivalent so it should fail when using one method once and the other another time.Proposed Solution
Remove the interface by extending this if:
plone.app.registry/plone/app/registry/exportimport/handler.py
Lines 255 to 258 in 04e431b
like so:
Or we set the old
interfaceName
to the new field like so:In the second solution, the fieldName could also be reused from the old field if possible.
The text was updated successfully, but these errors were encountered: