Changeset 3545 in products for quintagroup.z3cform.captcha/trunk
- Timestamp:
- Sep 10, 2012 4:50:46 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.z3cform.captcha/trunk/quintagroup/z3cform/captcha/widget.py
r3544 r3545 12 12 def __init__(self, value): 13 13 self.value = value 14 14 15 def __str__(self): 15 16 return repr(self.value) … … 17 18 18 19 class CaptchaWidget(TextWidget): 19 20 def getCaptcha(self):21 try:22 return self.form.context.getCaptcha()23 except AttributeError:24 raise CaptchaError('quintagroup.captcha.core not installed. '25 'Install quintagroup.captcha.core using Quickinstaller or Plone Control Panel')26 20 27 def render(self): 28 key = self.getCaptcha() 29 portal_url = getToolByName(self.form.context, 'portal_url')() 30 image_url = "%s/getCaptchaImage/%s"%(portal_url, key) 21 def getCaptcha(self): 22 try: 23 return self.form.context.getCaptcha() 24 except AttributeError: 25 raise CaptchaError('quintagroup.captcha.core not installed. ' 26 'Install quintagroup.captcha.core using ' 27 'Quickinstaller or Plone Control Panel') 31 28 32 return u"""<input type="hidden" value="%s" name="%shashkey" /> 29 def render(self): 30 key = self.getCaptcha() 31 portal_url = getToolByName(self.form.context, 'portal_url')() 32 image_url = "%s/getCaptchaImage/%s" % (portal_url, key) 33 34 return u"""<input type="hidden" value="%s" name="%shashkey" /> 33 35 %s 34 36 <img src="%s" alt="Enter the word"/>""" % (key, … … 36 38 super(CaptchaWidget, self).render(), 37 39 image_url) 38 return super(CaptchaWidget, self).template(self) 40 return super(CaptchaWidget, self).template(self) 41 39 42 40 43 @implementer(interfaces.IFieldWidget)
Note: See TracChangeset
for help on using the changeset viewer.