From ce30a1b59489a44c7bb4c482b551f529a17f65d2 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Thu, 13 Aug 2009 18:53:27 +0000 Subject: [PATCH] remove SimpleFieldValidator import fallback, because it breaks the CaptchaValidator. svn path=/plone.app.discussion/trunk/; revision=28789 --- plone/app/discussion/browser/captcha.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/plone/app/discussion/browser/captcha.py b/plone/app/discussion/browser/captcha.py index 9a3c4f6..50a0eb7 100644 --- a/plone/app/discussion/browser/captcha.py +++ b/plone/app/discussion/browser/captcha.py @@ -27,21 +27,14 @@ try: from plone.formwidget.captcha.validator import CaptchaValidator HAS_CAPTCHA = True except ImportError: - # Fall back to SimpleFieldValidator, when Captcha is not installed, - # since otherwise the registration of the Captcha validator adapter - # would fail. - from z3c.form.validator import SimpleFieldValidator as CaptchaValidator + pass HAS_RECAPTCHA = False try: from plone.formwidget.recaptcha import ReCaptchaFieldWidget HAS_RECAPTCHA = True except ImportError: - # Fall back to SimpleFieldValidator, when ReCaptcha is not installed, - # since otherwise the registration of the ReCaptcha validator adapter - # would fail. - from z3c.form.validator import SimpleFieldValidator as CaptchaValidator - + pass class Captcha(Persistent): interface.implements(ICaptcha) @@ -51,6 +44,7 @@ class Captcha(Persistent): Captcha = factory(Captcha) if HAS_CAPTCHA or HAS_RECAPTCHA: + # Extend the comment form with captcha, only if a captcha solution is installed. class CaptchaExtender(extensible.FormExtender): adapts(Interface, IDefaultBrowserLayer, CommentForm) # context, request, form @@ -78,9 +72,6 @@ if HAS_CAPTCHA or HAS_RECAPTCHA: # If ReCaptcha is installed and ReCaptcha is enabled, # use the ReCaptchaFieldWidget self.form.fields['captcha'].widgetFactory = ReCaptchaFieldWidget - else: - # - pass # Register Captcha validator for the captcha field in the ICaptchaForm validator.WidgetValidatorDiscriminators(CaptchaValidator, field=ICaptcha['captcha'])