Akismet spam protection plugin support added (collective.akismet).

svn path=/plone.app.discussion/trunk/; revision=37136
This commit is contained in:
Timo Stollenwerk 2010-06-10 13:11:33 +00:00
parent 92766752c4
commit 926314ea49
2 changed files with 20 additions and 4 deletions

View File

@ -6,7 +6,7 @@ from persistent import Persistent
from Products.CMFCore.utils import getToolByName
from z3c.form import validator
from z3c.form import interfaces, validator
from z3c.form.field import Fields
from zope import interface, schema
@ -70,4 +70,5 @@ class CaptchaExtender(extensible.FormExtender):
elif self.captcha == 'recaptcha':
from plone.formwidget.recaptcha import ReCaptchaFieldWidget
self.form.fields['captcha'].widgetFactory = ReCaptchaFieldWidget
elif self.captcha == 'akismet':
self.form.fields['captcha'].mode = interfaces.HIDDEN_MODE

View File

@ -5,20 +5,28 @@ import zope.schema.vocabulary
from plone.app.discussion.interfaces import _
HAS_CAPTCHA=False
HAS_CAPTCHA = False
try:
import plone.formwidget.captcha
HAS_CAPTCHA = True
except ImportError:
pass
HAS_RECAPTCHA=False
HAS_RECAPTCHA = False
try:
import plone.formwidget.recaptcha
HAS_RECAPTCHA = True
except ImportError:
pass
HAS_AKISMET = False
try:
from akismet import Akismet, AkismetError
HAS_AKISMET = True
except ImportError:
pass
def captcha_vocabulary(context):
"""Vocabulary with all available captcha implementations.
"""
@ -41,6 +49,13 @@ def captcha_vocabulary(context):
value='recaptcha',
token='recaptcha',
title='ReCaptcha'))
if HAS_AKISMET:
terms.append(
zope.schema.vocabulary.SimpleTerm(
value='akismet',
token='akismet',
title='Akismet'))
return zope.schema.vocabulary.SimpleVocabulary(terms)
interface.alsoProvides(captcha_vocabulary,