Skip to content

Commit

Permalink
more bda.plone.shop related fieldnames
Browse files Browse the repository at this point in the history
  • Loading branch information
thet committed Feb 18, 2015
1 parent 7fa01de commit c70b847
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions collective/jsonify/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ def get_archetypes_fields(self):
if type_[0] == '_' and type_.endswith('ExtensionField'):
type_ = type_[1: -len('ExtensionField')] + 'Field'

string_fieldnames = [
'StringField',
'TextField',
'XStringField', # from bda.plone.shop
'XTextField', # from bda.plone.shop
]
fieldnames = [
'BooleanField',
'ComputedField',
Expand All @@ -390,19 +396,17 @@ def get_archetypes_fields(self):
'IntegerField',
'LinesField',
'SimpleDataGridField',
'StringField',
'TALESLines',
'TALESString',
'TextField',
'ZPTField',
'LeadimageCaptionField', # from collective.contentleadimage
'XStringField', # from bda.plone.shop
'XFloatField', # from bda.plone.shop
'XBooleanField', # from bda.plone.shop
'XTextField', # from bda.plone.shop
'XSharedStockBooleanField', # from bda.plone.ticketshop
'XSharedStockFloatField', # from bda.plone.ticketshop
]

if type_ in fieldnames:
if type_ in string_fieldnames + fieldnames:
try:
value = field.getRaw(self.context)
except AttributeError:
Expand All @@ -415,7 +419,7 @@ def get_archetypes_fields(self):
if isinstance(value, str):
value = value.decode('utf-8')

if value and type_ in ['StringField', 'TextField']:
if value and type_ in string_fieldnames:
try:
value = self.decode(value)
except AttributeError:
Expand All @@ -434,7 +438,7 @@ def get_archetypes_fields(self):

self[unicode(fieldname)] = value

if value and type_ in ['TextField', 'StringField']:
if value and type_ in string_fieldnames:
try:
ct = field.getContentType(self.context)
self[unicode('_content_type_') + fieldname] = ct
Expand All @@ -444,6 +448,7 @@ def get_archetypes_fields(self):
elif type_ in [
'DateTimeField',
'XDateTimeField', # from bda.plone.shop
'XSharedBuyablePeriodDateTimeField', # from bda.plone.ticketshop # noqa
]:
value = str(self._get_at_field_value(field))
if value:
Expand Down

0 comments on commit c70b847

Please sign in to comment.