2009-08-11 11:45:34 +02:00
|
|
|
from zope import interface
|
|
|
|
from zope import component
|
|
|
|
import zope.schema.interfaces
|
|
|
|
import zope.schema.vocabulary
|
|
|
|
|
2010-01-24 14:47:39 +01:00
|
|
|
from plone.app.discussion.interfaces import _
|
|
|
|
|
2009-08-11 11:45:34 +02:00
|
|
|
HAS_CAPTCHA=False
|
|
|
|
try:
|
2009-08-15 12:18:10 +02:00
|
|
|
import plone.formwidget.captcha
|
2009-08-11 11:45:34 +02:00
|
|
|
HAS_CAPTCHA = True
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2009-08-15 12:18:10 +02:00
|
|
|
HAS_RECAPTCHA=False
|
2009-08-11 11:45:34 +02:00
|
|
|
try:
|
2009-08-15 12:18:10 +02:00
|
|
|
import plone.formwidget.recaptcha
|
2009-08-11 11:45:34 +02:00
|
|
|
HAS_RECAPTCHA = True
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def captcha_vocabulary(context):
|
|
|
|
"""Vocabulary with all available captcha implementations.
|
|
|
|
"""
|
|
|
|
terms = []
|
|
|
|
terms.append(
|
|
|
|
zope.schema.vocabulary.SimpleTerm(
|
|
|
|
value='disabled',
|
|
|
|
token='disabled',
|
2010-01-24 14:47:39 +01:00
|
|
|
title=_(u'Disabled')))
|
2009-08-11 11:45:34 +02:00
|
|
|
|
|
|
|
if HAS_CAPTCHA:
|
|
|
|
terms.append(
|
|
|
|
zope.schema.vocabulary.SimpleTerm(
|
|
|
|
value='captcha',
|
|
|
|
token='captcha',
|
|
|
|
title='Captcha'))
|
|
|
|
if HAS_RECAPTCHA:
|
|
|
|
terms.append(
|
|
|
|
zope.schema.vocabulary.SimpleTerm(
|
|
|
|
value='recaptcha',
|
|
|
|
token='recaptcha',
|
|
|
|
title='ReCaptcha'))
|
|
|
|
return zope.schema.vocabulary.SimpleVocabulary(terms)
|
|
|
|
|
|
|
|
interface.alsoProvides(captcha_vocabulary,
|
|
|
|
zope.schema.interfaces.IVocabularyFactory)
|