def __call__(self): field_list = self.request.form.get('items.fl', '').strip() if field_list: field_list = field_list.split(',') else: field_list = ['@type', 'title', 'description', 'review_state'] obj = IContentListingObject(self.context) summary = json_compatible({ '@id': obj.getURL(), }) for field in field_list: accessor = FIELD_ACCESSORS.get(field) if accessor is None: continue if isinstance(accessor, str): value = getattr(obj, accessor, None) if callable(value): value = value() else: value = accessor(obj) summary[field] = json_compatible(value) if ('title' in summary and ITranslatedTitleSupport.providedBy(self.context)): # Update title to contain translated title in negotiated language attr = 'title_{}'.format(get_preferred_language_code()) summary['title'] = getattr(self.context, attr) return summary
def __call__(self): # Get the default summary first, then modify it as needed summary = super(GeverJSONSummarySerializer, self).__call__() # Include portal_type summary['@type'] = self.context.portal_type if ITranslatedTitleSupport.providedBy(self.context): # Update title to contain translated title in negotiated language attr = 'title_{}'.format(get_preferred_language_code()) summary['title'] = getattr(self.context, attr) return summary
def get_title(self, obj): if ITranslatedTitleSupport.providedBy(obj): return ITranslatedTitle(obj).title_de return obj.title
def translated_title(obj): if ITranslatedTitleSupport.providedBy(obj): attr = 'title_{}'.format(get_preferred_language_code()) return getattr(obj, attr, obj.Title()) else: return obj.Title()
def title_fr_indexer(obj): if ITranslatedTitleSupport.providedBy(obj): return ITranslatedTitle(obj).title_fr return None