From 4f13054ae43eec6fb626e7bdd37ba6047f93e6df Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Mon, 31 May 2010 09:50:46 +0000 Subject: [PATCH] plone.z3cform 0.6.0 compatibility (fix maximum recursion depth error which appears with plone.z3cform higher than 0.5.10); [piv] svn path=/plone.app.discussion/trunk/; revision=36843 --- CHANGES.txt | 5 +++++ plone/app/discussion/browser/comments.py | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index a319166..21ae8b1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,11 @@ Changelog 1.0b5 (unreleased) ------------------ + +* plone.z3cform 0.6.0 compatibility (fix maximum recursion depth error which + appears with plone.z3cform higher than 0.5.10) + [piv] + * Removed moderation.js from js registry and include it only in moderation.pt as that is the only place where it is used. [ggozad] diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index 8758813..f78a5ce 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -13,7 +13,7 @@ from zope.annotation import IAttributeAnnotatable from zope.component import createObject, getMultiAdapter, queryUtility -from zope.interface import Interface, implements +from zope.interface import Interface, implements, alsoProvides from zope.viewlet.interfaces import IViewlet @@ -42,6 +42,12 @@ from plone.app.discussion.browser.validator import CaptchaValidator from plone.z3cform import layout, z2 from plone.z3cform.fieldsets import extensible +# starting from 0.6.0 version plone.z3cform has IWrappedForm interface +try: + from plone.z3cform.interfaces import IWrappedForm + HAS_WRAPPED_FORM = True +except ImportError: + HAS_WRAPPED_FORM = True class CommentForm(extensible.ExtensibleForm, form.Form): @@ -201,6 +207,8 @@ class CommentsViewlet(ViewletBase): super(CommentsViewlet, self).update() z2.switch_on(self, request_layer=IFormLayer) self.form = CommentForm(aq_inner(self.context), self.request) + if HAS_WRAPPED_FORM: + alsoProvides(self.form, IWrappedForm) self.form.update() # view methods