def render(self, type='article', **kwargs): spec = {'status':'published'} type = getattr(CONTENT_TYPE, type.upper(), CONTENT_TYPE.ARTICLE) spec.update({'type': type}) limit = kwargs.pop('limit', 3) items = Content.all(spec).sort([('created_at', -1)]).limit(limit) if items: return self.render_string('modules/content-latest', items=items) else: return ''
def _extra_context(self, context): extras = { "today": date.today(), "yesterday": date.today() - timedelta(1), "this_month": date.today(), "last_month": date.today() - timedelta(monthrange(date.today().year, date.today().month)[1]), } path = self.request.path content = Content.all().filter('path =', path) content_extras = {} for item in content: content_extras[item.ident] = item.value context.update(extras) context.update(content_extras) return context