Changeset 3453 in products
- Timestamp:
- Apr 26, 2012 10:13:56 AM (12 years ago)
- Location:
- quintagroup.plonecaptchas/branches/captcha_provider/quintagroup/plonecaptchas
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonecaptchas/branches/captcha_provider/quintagroup/plonecaptchas/captcha.py
r3445 r3453 6 6 from quintagroup.plonecaptchas.interfaces import ICaptchaProvider 7 7 from zope.interface import Interface 8 from zope.component import adapts, get Adapters, queryAdapter8 from zope.component import adapts, getUtilitiesFor, queryUtility 9 9 from plone.app.discussion.browser.comments import CommentForm 10 10 … … 12 12 class CaptchaProvider(object): 13 13 14 def __init__(self , context):14 def __init__(self): 15 15 self.widget_factory = CaptchaWidgetFactory 16 16 … … 21 21 def update(self): 22 22 super(CaptchaExtender, self).update() 23 providers = getAdapters((self.context,), ICaptchaProvider) 24 if self.captcha in (n for n, a in providers) and self.isAnon: 25 captcha_provider = queryAdapter((self.context,), name=self.captcha) 23 if self.isAnon: 24 captcha_provider = queryUtility(ICaptchaProvider, name=self.captcha) 26 25 if captcha_provider: 27 26 self.form.fields['captcha'].widgetFactory = \ … … 33 32 """ Extend captcha vocabulary with quintagroup.plonecaptchas""" 34 33 terms = vocabularies.captcha_vocabulary(context)._terms 35 captchas = [t.value for t in terms]34 captchas = set((t.value for t in terms)) 36 35 37 adapters = getAdapters((context,),ICaptchaProvider)38 for name, adapter in adapters:36 providers = getUtilitiesFor(ICaptchaProvider) 37 for name, util in providers: 39 38 if name and name not in captchas: 40 terms.append(SimpleTerm(value=name .lower(),41 token=name .lower(),42 title=name [0].upper() + name[1:]))39 terms.append(SimpleTerm(value=name, 40 token=name, 41 title=name.capitalize())) 43 42 return SimpleVocabulary(terms) -
quintagroup.plonecaptchas/branches/captcha_provider/quintagroup/plonecaptchas/configure.zcml
r3439 r3453 27 27 <configure zcml:condition="installed plone.app.discussion"> 28 28 29 < adapter29 <utility 30 30 factory=".captcha.CaptchaProvider" 31 for="zope.component.Interface"32 31 provides="quintagroup.plonecaptchas.interfaces.ICaptchaProvider" 33 32 name="plonecaptchas"
Note: See TracChangeset
for help on using the changeset viewer.