From 98bcc19d5cf2709c9317540ea3c07e5a5ca7ef02 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Thu, 16 Jun 2011 10:59:25 +0000 Subject: [PATCH] Do not render/update the comment form in CommentViewlets if commenting is disabled, since this slows down the page rendering. This fixes http://dev.plone.org/plone/ticket/11930 #11930 svn path=/plone.app.discussion/trunk/; revision=50489 --- CHANGES.txt | 5 +++++ plone/app/discussion/browser/comments.py | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7079ef0..cd53525 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,6 +14,11 @@ Changelog Related to https://dev.plone.org/plone/ticket/11737 [WouterVH] +- Do not render/update the comment form in CommentViewlets if commenting is + disabled, since this slows down the page rendering. This fixes + http://dev.plone.org/plone/ticket/11930 + [fafhrd] + 2.0.4 (2011-05-28) ------------------ diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index d9f0431..159d3af 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -248,10 +248,13 @@ class CommentsViewlet(ViewletBase): def update(self): super(CommentsViewlet, self).update() - z2.switch_on(self, request_layer=IFormLayer) - self.form = self.form(aq_inner(self.context), self.request) - alsoProvides(self.form, IWrappedForm) - self.form.update() + if self.is_discussion_allowed() and \ + (self.is_anonymous() and self.anonymous_discussion_allowed() \ + or self.can_reply()): + z2.switch_on(self, request_layer=IFormLayer) + self.form = self.form(aq_inner(self.context), self.request) + alsoProvides(self.form, IWrappedForm) + self.form.update() # view methods