Skip to content

Commit

Permalink
Not all named file fields are provided via a behavior...
Browse files Browse the repository at this point in the history
  • Loading branch information
pysailor committed Feb 8, 2019
1 parent 1c0098a commit fed6886
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plone/app/versioningbehavior/modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from plone.behavior.registration import lookup_behavior_registration
from plone.dexterity.interfaces import IDexterityContent
from plone.dexterity.utils import iterSchemata
from plone.dexterity.utils import resolveDottedName
from plone.namedfile.interfaces import INamedBlobFileField
from plone.namedfile.interfaces import INamedBlobImageField
from Products.CMFCore.utils import getToolByName
Expand Down Expand Up @@ -170,6 +171,7 @@ def reattachReferencedAttributes(self, obj, attrs_dict):
obj = aq_base(obj)
for name, blob in six.iteritems(attrs_dict):
iface_name, f_name = name.rsplit('.', 1)
# In case the field is provided via a behavior:
# Look up the behavior via dotted name.
# If the behavior's dotted name was changed, we might still have
# the old name in our attrs_dict.
Expand All @@ -178,9 +180,10 @@ def reattachReferencedAttributes(self, obj, attrs_dict):
# be found.
try:
behavior = lookup_behavior_registration(iface_name)
iface = behavior.interface
except BehaviorRegistrationNotFound:
return
iface = behavior.interface
# Not a behavior - fetch the interface directly
iface = resolveDottedName(iface_name)
field = iface.get(f_name)
if field is not None: # Field may have been removed from schema
adapted_field = field.get(iface(obj))
Expand Down

0 comments on commit fed6886

Please sign in to comment.