Skip to content

Commit

Permalink
Handle case of empty field defined by a behaviour schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdelcourt committed Nov 1, 2014
1 parent ad1dc3b commit 8339558
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Products/CMFDiffTool/BaseDiff.py
Expand Up @@ -13,6 +13,8 @@
from Products.CMFDiffTool.interfaces import IDifference
from Products.CMFDiffTool import CMFDiffToolMessageFactory as _

from plone.dexterity.interfaces import IDexterityContent


class BaseDiff:
"""Basic diff type"""
Expand Down Expand Up @@ -70,7 +72,11 @@ def _getValue(ob, field, field_name, convert_to_str=True):
# Check for the attribute without acquisition. If it's there,
# grab it *with* acquisition, so things like ComputedAttribute
# will work
if field and hasattr(aq_base(ob), field):
if field_name and hasattr(aq_base(ob), field_name):
value = getattr(ob, field_name)
elif IDexterityContent.providedBy(ob):
return field.default
elif field and hasattr(aq_base(ob), field):
value = getattr(ob, field)
elif hasattr(aq_base(ob), 'getField'):
# Archetypes with an adapter extended schema needs special handling
Expand Down
2 changes: 1 addition & 1 deletion Products/CMFDiffTool/dexteritydiff.py
Expand Up @@ -119,7 +119,7 @@ def _diff_field(self, obj1, obj2, field, schema_name):
return diff_type(
obj1,
obj2,
field.getName(),
field,
id1=self.id1,
id2=self.id2,
field_name=field.getName(),
Expand Down

0 comments on commit 8339558

Please sign in to comment.