Ignore:
Timestamp:
Sep 10, 2012 4:50:46 PM (12 years ago)
Author:
vmaksymiv
Message:

PPP fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.z3cform.captcha/trunk/quintagroup/z3cform/captcha/widget.py

    r3544 r3545  
    1212    def __init__(self, value): 
    1313        self.value = value 
     14 
    1415    def __str__(self): 
    1516        return repr(self.value) 
     
    1718 
    1819class 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') 
    2620 
    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') 
    3128 
    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" /> 
    3335                   %s 
    3436                   <img src="%s" alt="Enter the word"/>""" % (key, 
     
    3638                                                              super(CaptchaWidget, self).render(), 
    3739                                                              image_url) 
    38        return super(CaptchaWidget, self).template(self)  
     40        return super(CaptchaWidget, self).template(self) 
     41 
    3942 
    4043@implementer(interfaces.IFieldWidget) 
Note: See TracChangeset for help on using the changeset viewer.