Move AkismetValidator from plone.app.discussion to collective.akismet.
svn path=/plone.app.discussion/trunk/; revision=37764
This commit is contained in:
parent
5784ed82a3
commit
f3b1dab916
@ -19,17 +19,13 @@
|
|||||||
<meta:provides feature="plone.app.discussion-captcha" />
|
<meta:provides feature="plone.app.discussion-captcha" />
|
||||||
</configure>
|
</configure>
|
||||||
|
|
||||||
<configure zcml:condition="installed collective.akismet">
|
|
||||||
<meta:provides feature="plone.app.discussion-captcha" />
|
|
||||||
</configure>
|
|
||||||
|
|
||||||
<!-- Captcha comment form extender -->
|
<!-- Captcha comment form extender -->
|
||||||
<configure zcml:condition="have plone.app.discussion-captcha">
|
<configure zcml:condition="have plone.app.discussion-captcha">
|
||||||
<!--
|
<!--
|
||||||
Register the Captcha form extender and validator only if there are
|
Register the Captcha form extender and validator only if there are
|
||||||
plugins installed that declare to implement a Captcha solution for
|
plugins installed that declare to implement a Captcha solution for
|
||||||
plone.app.discussion (e.g. plone.formwidget.captcha and
|
plone.app.discussion (e.g. plone.formwidget.captcha and
|
||||||
plone.formwidget.recaptcha, collective.akismet).
|
plone.formwidget.recaptcha).
|
||||||
-->
|
-->
|
||||||
<adapter
|
<adapter
|
||||||
factory=".captcha.Captcha"
|
factory=".captcha.Captcha"
|
||||||
@ -43,4 +39,12 @@
|
|||||||
/>
|
/>
|
||||||
</configure>
|
</configure>
|
||||||
|
|
||||||
|
<!-- Akismet Validator -->
|
||||||
|
<configure zcml:condition="installed collective.akismet">
|
||||||
|
<adapter
|
||||||
|
factory="collective.akismet.validator.AkismetValidator"
|
||||||
|
provides="z3c.form.interfaces.IValidator"
|
||||||
|
/>
|
||||||
|
</configure>
|
||||||
|
|
||||||
</configure>
|
</configure>
|
@ -33,11 +33,6 @@ try:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
|
||||||
from collective.akismet.browser.validator import AkismetReject
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
from zope.interface import implements, Interface
|
from zope.interface import implements, Interface
|
||||||
from zope.schema.interfaces import IField
|
from zope.schema.interfaces import IField
|
||||||
from zope.component import adapts
|
from zope.component import adapts
|
||||||
@ -57,14 +52,11 @@ class CaptchaValidator(validator.SimpleFieldValidator):
|
|||||||
registry = queryUtility(IRegistry)
|
registry = queryUtility(IRegistry)
|
||||||
settings = registry.forInterface(IDiscussionSettings)
|
settings = registry.forInterface(IDiscussionSettings)
|
||||||
|
|
||||||
if settings.captcha != 'disabled':
|
if settings.captcha == 'captcha' or settings.captcha == 'recaptcha':
|
||||||
captcha = getMultiAdapter((aq_inner(self.context), self.request),
|
captcha = getMultiAdapter((aq_inner(self.context), self.request),
|
||||||
name=settings.captcha)
|
name=settings.captcha)
|
||||||
if not captcha.verify(input=value):
|
if not captcha.verify(input=value):
|
||||||
if settings.captcha == 'akismet':
|
raise WrongCaptchaCode
|
||||||
raise AkismetReject
|
|
||||||
else:
|
|
||||||
raise WrongCaptchaCode
|
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user