def __init__(self, context, request, manager, view): super(BlogRecentCommentsPortlet, self).__init__( context, request, manager, view) blog = context.get('blog') if not IBlog.providedBy(blog): return self.blog = True self.context = blog
def update(self): context = self.context blog = context while not IBlog.providedBy(blog): blog = getattr(blog, '__parent__', None) if blog is None: return self.blog = blog self.batch = Batch( context.entries(), size=blog.pageSize, context=context, request=self.request) self.ids = getUtility(IIntIds) self.announce = getUtility(IBloggerProduct).usePostAbstractField
def update(self): context = self.context while not ISpace.providedBy(context): context = context.__parent__ try: blog = context.get('blog') if not IBlog.providedBy(blog): return except: return self.blog = True self.context = blog self.blog_url = absoluteURL(removeAllProxies(blog), self.request) super(BlogTagsPortlet, self).update()
def update(self): context = self.context while not ISpace.providedBy(context): context = context.__parent__ try: blog = context.get('blog') if not IBlog.providedBy(blog): return except: return if 'category' not in blog: return categories = [] for category in blog['category'].values(): categories.append((category.title, category.__name__)) categories.sort() self.categories = [{'name':name, 'title':title} for title, name in categories]
def update(self): super(BasePostView, self).update() post = removeAllProxies(self.context) request = self.request owner = IOwnership(post).owner profile = IPersonalProfile(owner, None) space = getattr(profile, 'space', None) profileData = profile.getProfileData() self.post = post self.postUrl = absoluteURL(post, request) self.text = getattr(self.context.text, 'cooked', '') self.biography = profileData.get('about', False) self.jobtitle = profileData.get('jobtitle', False) if self.biography: self.biography = re.sub('<[^>]*>', '', self.biography.text) if len(self.biography) >= 240: self.biography = self.biography[:240].rsplit(' ', 1)[0].strip() + '...' # blog if IDraftedContent.providedBy(post): blog = post.__parent__ location = blog.getLocation() if location is not None: blog = location.get('blog') else: blog = None else: blog = post.__parent__ if IBlog.providedBy(blog): self.blog = blog self.blog_title = blog.title self.blog_url = absoluteURL(blog, request) self.tags_list = blog['tags'].listTags(post) # author try: self.author = profile.title self.avatar_url = profile.avatarUrl(request) except AttributeError: self.author = getattr(owner, 'title', '') self.avatar_url = '#' if space is not None: self.profile_url = '%s/profile/' % absoluteURL(space, request) # discussion discussion = IContentDiscussion(post, None) self.comments = discussion is not None and len(discussion) self.discussible = discussion is not None and discussion.status != 3 self.footer_discussion = self.discussible and self.comments_num # categories categories = [] ids = getUtility(IIntIds) for cId in post.category: category = ids.queryObject(cId) if category is not None: categories.append( (category.title, {'name': category.__name__, 'title': category.title})) categories.sort() self.categories = [info for t, info in categories] self.footer = self.categories or \ self.tags_list or self.footer_discussion