Ignore:
Timestamp:
Apr 15, 2011 1:00:00 PM (13 years ago)
Author:
vmaksymiv
Message:

pep8 fixes

File:
1 edited

Legend:

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

    r3098 r3121  
    2323logger = logging.getLogger('quintagroup.formlib.captcha') 
    2424 
     25 
    2526class CaptchaWidget(ASCIIWidget): 
    2627 
     
    4243 
    4344        site = self.get_site() 
    44         portal_url = getToolByName(site , 'portal_url')() 
     45        portal_url = getToolByName(site, 'portal_url')() 
    4546        key = site.getCaptcha() 
    4647 
     
    5253        return u"""<input type="hidden" value="%s" name="%shashkey" /> 
    5354                   %s 
    54                    <img src="%s/getCaptchaImage/%s" alt="Enter the word"/>""" % (key, 
    55                                                                                  prefix, 
    56                                                                                  renderElement(self.tag, **kwargs), 
    57                                                                                  portal_url, 
    58                                                                                  key) 
    59           
     55                   <img src="%s/getCaptchaImage/%s" 
     56                        alt="Enter the word"/>""" % (key, 
     57                                                     prefix, 
     58                                                     renderElement(self.tag, 
     59                                                                   **kwargs), 
     60                                                     portal_url, 
     61                                                     key) 
     62 
    6063    def _toFieldValue(self, input): 
    6164        # Verify the user input against the captcha 
     
    6467        site = self.get_site() 
    6568        captcha_type = site.getCaptchaType() 
    66          
     69 
    6770        # validate captcha input 
    6871        if input and captcha_type in ['static', 'dynamic']: 
     
    7275            else: 
    7376                prefix = '' 
    74              
     77 
    7578            hashkey = self.request.get('%shashkey' % prefix, '') 
    7679            decrypted_key = decrypt(site.captcha_key, hashkey) 
    7780            parsed_key = parseKey(decrypted_key) 
    78              
     81 
    7982            index = parsed_key['key'] 
    8083            date = parsed_key['date'] 
    81              
     84 
    8285            if captcha_type == 'static': 
    8386                img = getattr(site, '%s.jpg' % index) 
     
    8790                enc = input 
    8891                solution = getWord(int(index)) 
    89              
     92 
    9093            captcha_tool = getToolByName(site, 'portal_captchas') 
    91             if (enc != solution) or (captcha_tool.has_key(decrypted_key)) or (DateTime().timeTime() - float(date) > 3600): 
     94            if (enc != solution) or (decrypted_key in captcha_tool) or \ 
     95               (DateTime().timeTime() - float(date) > 3600): 
    9296                raise ConversionError(_(u'Please re-enter validation code.')) 
    9397            else: 
    9498                captcha_tool.addExpiredKey(decrypted_key) 
    95          
     99 
    96100        return super(CaptchaWidget, self)._toFieldValue(input) 
Note: See TracChangeset for help on using the changeset viewer.