Changeset 7296 for main/waeup.sirp/trunk/src/waeup/sirp/browser
- Timestamp:
- 7 Dec 2011, 00:13:12 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/captcha.py
r7292 r7296 23 23 import urllib 24 24 import urllib2 25 from random import SystemRandom as random 25 26 from zope import schema 26 27 from zope.component import getUtilitiesFor, getUtility, queryUtility … … 142 143 default=getUtility(ICaptcha)) 143 144 144 # 145 # Trivial default captcha146 # 145 ## 146 ## Trivial default captcha 147 ## 147 148 class CaptchaResponse(object): 148 149 grok.implements(ICaptchaResponse) … … 184 185 grok.global_utility(NullCaptcha, name=u'') 185 186 186 # 187 # ReCaptcha 188 # 187 ## 188 ## TestCaptcha 189 ## 190 class IdCaptcha(object): 191 grok.implements(ICaptcha) 192 193 def verify(self, request): 194 if request.solution == request.challenge and request.solution: 195 return CaptchaResponse(is_valid=True) 196 return CaptchaResponse(is_valid=False) 197 198 def display(self, error_code=None): 199 challenge = list('abcdef') 200 random().shuffle(challenge) 201 challenge = ''.join(challenge) 202 html = ( 203 u'<input type="hidden" name="challenge"' 204 u' value="%s" /><br />' 205 u'Type: %s<br />' 206 u'<input type="text" name="solution" /><br />' % ( 207 challenge, challenge)) 208 return html 209 210 grok.global_utility(IdCaptcha, name=u'Testing captcha') 211 212 213 ## 214 ## ReCaptcha 215 ## 189 216 API_SSL_SERVER = "https://www.google.com/recaptcha/api" 190 217 VERIFY_SERVER = "http://www.google.com"
Note: See TracChangeset for help on using the changeset viewer.