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