Skip to content

Commit

Permalink
Don't skip ComputedField fields, but just export their computed value…
Browse files Browse the repository at this point in the history
…. Better skip them in your transmogrifier import pipeline.
  • Loading branch information
thet committed Jan 29, 2015
1 parent c2cee54 commit 228e7d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog
0.3 (unreleased)
----------------

- Don't skip ``ComputedField`` fields, but just export their computed value.
Better skip them in your transmogrifier import pipeline.
[thet]

- Allow a ``skip_callback`` function to be passed to the ``export_content``
function. It evaluates to ``True``, if the current visited item should be
excluded from exporting.
Expand Down
8 changes: 5 additions & 3 deletions collective/jsonify/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ def get_archetypes_fields(self):

fieldnames = [
'BooleanField',
'ComputedField',
'DataGridField',
'EmailField',
'FixedPointField',
Expand All @@ -396,6 +397,10 @@ def get_archetypes_fields(self):
if callable(value):
value = value()

if value and type_ in ['ComputedField']:
if isinstance(value, str):
value = value.decode('utf-8')

if value and type_ in ['StringField', 'TextField']:
try:
value = self.decode(value)
Expand Down Expand Up @@ -490,9 +495,6 @@ def get_archetypes_fields(self):
if value:
self[fieldname] = value

elif type_ in ['ComputedField']:
continue

elif type_ in ['QueryField']:
value = field.getRaw(self.context)
self[fieldname] = [dict(q) for q in value]
Expand Down

0 comments on commit 228e7d0

Please sign in to comment.