Changeset 3457 in products for quintagroup.plonecaptchas/trunk/quintagroup/plonecaptchas
- Timestamp:
- Apr 26, 2012 12:21:41 PM (12 years ago)
- Location:
- quintagroup.plonecaptchas/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonecaptchas/trunk
- Property svn:mergeinfo
-
old new 1 /quintagroup.plonecaptchas/branches/captcha_provider:3438-3456 1 2 /quintagroup.plonecaptchas/branches/split2packs:1946-2024
-
- Property svn:mergeinfo
-
quintagroup.plonecaptchas/trunk/quintagroup/plonecaptchas/captcha.py
r3428 r3457 3 3 from plone.app.discussion import vocabularies 4 4 from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm 5 from z3c.form import interfaces6 from quintagroup.plonecaptchas.config import CAPTCHA_NAME7 5 from quintagroup.plonecaptchas.interfaces import IQGDiscussionCaptchas 6 from quintagroup.plonecaptchas.interfaces import ICaptchaProvider 8 7 from zope.interface import Interface 9 from zope.component import adapts 8 from zope.component import adapts, getUtilitiesFor, queryUtility 10 9 from plone.app.discussion.browser.comments import CommentForm 10 11 12 class CaptchaProvider(object): 13 14 def __init__(self): 15 self.widget_factory = CaptchaWidgetFactory 11 16 12 17 … … 16 21 def update(self): 17 22 super(CaptchaExtender, self).update() 18 if self.captcha == CAPTCHA_NAME and self.isAnon: 19 self.form.fields['captcha'].widgetFactory = CaptchaWidgetFactory 20 if self.form.fields['captcha'].mode == interfaces.HIDDEN_MODE: 23 if self.isAnon: 24 captcha_provider = queryUtility(ICaptchaProvider, 25 name=self.captcha) 26 if captcha_provider: 27 self.form.fields['captcha'].widgetFactory = \ 28 captcha_provider.widget_factory 21 29 self.form.fields['captcha'].mode = None 22 30 … … 25 33 """ Extend captcha vocabulary with quintagroup.plonecaptchas""" 26 34 terms = vocabularies.captcha_vocabulary(context)._terms 27 terms.append(SimpleTerm(value=CAPTCHA_NAME, 28 token=CAPTCHA_NAME, 29 title=CAPTCHA_NAME)) 35 captchas = set((t.value for t in terms)) 36 37 providers = getUtilitiesFor(ICaptchaProvider) 38 for name, util in providers: 39 if name and name not in captchas: 40 terms.append(SimpleTerm(value=name, 41 token=name, 42 title=name.capitalize())) 30 43 return SimpleVocabulary(terms) -
quintagroup.plonecaptchas/trunk/quintagroup/plonecaptchas/configure.zcml
r3428 r3457 26 26 27 27 <configure zcml:condition="installed plone.app.discussion"> 28 29 <utility 30 factory=".captcha.CaptchaProvider" 31 provides="quintagroup.plonecaptchas.interfaces.ICaptchaProvider" 32 name="plonecaptchas" 33 /> 28 34 29 35 <adapter -
quintagroup.plonecaptchas/trunk/quintagroup/plonecaptchas/interfaces.py
r3279 r3457 4 4 if HAS_APP_DISCUSSION: 5 5 from zope.publisher.interfaces.browser import IDefaultBrowserLayer 6 from zope.interface import Interface, Attribute 6 7 7 8 class IQGDiscussionCaptchas(IDefaultBrowserLayer): … … 10 11 """ 11 12 13 try: 14 from plone.app.discussion.interfaces import ICaptchaProvider 15 ICaptchaProvider # keep pyflakes quiet 16 except ImportError: 17 class ICaptchaProvider(Interface): 18 """ Captcha Provider 19 """ 20 widget_factory = Attribute("Chaptcha widget factory") 21 12 22 13 23 class IQGPloneCaptchas(IDefaultPloneLayer): -
quintagroup.plonecaptchas/trunk/quintagroup/plonecaptchas/meta.zcml
r3270 r3457 6 6 can be used by plone.app.discussion to add a Captcha field to comment 7 7 forms. --> 8 <meta:provides feature="plone.app.discussion-captcha" /> 8 9 <configure zcml:condition="installed plone.app.discussion"> 10 <meta:provides feature="plone.app.discussion-captcha" /> 11 <meta:provides feature="plone.app.discussion-captcha-provider" /> 12 </configure> 9 13 10 14 </configure> -
quintagroup.plonecaptchas/trunk/quintagroup/plonecaptchas/version.txt
r3447 r3457 1 4. 21 4.3-dev
Note: See TracChangeset
for help on using the changeset viewer.