def getBody(self,base_url=''): """ Body of mail """ #default values diff=-1 body=None #acquire aggregator utility from collective.plone.reader aggregator=self.context aggr_util=getMultiAdapter((self.context, self.request), name=u'aggregator_utility_view') #get recurrence from aggregator field=aggregator.getField('recurrence') if field: recurrence=field.get(aggregator) diff=RECURRENCE.get(recurrence,-1) #get contents from aggregator filtered date and limit date_limit=DateTime()-diff list_of_contents=aggr_util.getFavoritesByAggregator_not_merged(aggregator,'all',date_limit=date_limit,size_limit=10) #list_of_contents is a dictionary <section>: <list of contents> #and I want to know how many children there are childern=sum([len(folder['childs']) for folder in list_of_contents.values()]) #if there's no children we have no mail if childern>0: template=self.context.restrictedTraverse('mail_template') html=template(self, list_of_contents=list_of_contents, recurrence=LABEL_CONVERTER.get(recurrence), aggregator_url=aggregator.absolute_url(),) #if base_url is sets we replace the url of the template if len(base_url)>0: fake_portal_path='http://foo%s'%'/'.join(self.plone_site.getPhysicalPath()) html=html.replace(fake_portal_path,base_url) body = stoneagehtml.compactify(html).decode('utf-8') return body