Index: /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/example.py
===================================================================
--- /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/example.py	(revision 3120)
+++ /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/example.py	(revision 3121)
@@ -8,14 +8,14 @@
 from quintagroup.formlib.captcha import Captcha
 
+
 # Define CaptchaFormlibForm form schema
-
 class ICaptchaFormlibFormSchema(Interface):
     label = TextLine(title=u'Label',
                      required=False)
     captcha = Captcha(title=u'Type the code')
-      
+
+
 # Create adapter for any object to ICaptchaFormlibFormSchema
 # schema interface
-
 class CaptchaFormlibFormAdapter(object):
     implements(ICaptchaFormlibFormSchema)
@@ -26,7 +26,7 @@
     label = u''
     captcha = None
-      
+
+
 # And at the last define the CaptchaFormlibForm form
-
 class CaptchaFormlibForm(EditForm):
     form_fields = FormFields(ICaptchaFormlibFormSchema)
Index: /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/field.py
===================================================================
--- /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/field.py	(revision 3120)
+++ /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/field.py	(revision 3121)
@@ -3,4 +3,5 @@
 from interfaces import ICaptcha
 
+
 class Captcha(ASCIILine):
     implements(ICaptcha)
Index: /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/interfaces.py
===================================================================
--- /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/interfaces.py	(revision 3120)
+++ /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/interfaces.py	(revision 3121)
@@ -1,3 +1,4 @@
 from zope.schema.interfaces import IASCIILine
+
 
 class ICaptcha(IASCIILine):
Index: /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/tests/test_doctests.py
===================================================================
--- /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/tests/test_doctests.py	(revision 3120)
+++ /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/tests/test_doctests.py	(revision 3121)
@@ -15,4 +15,5 @@
 from quintagroup.captcha.core.tests.testWidget import addTestLayer
 
+
 class FormlibCaptchaLayer(PloneSite):
     @classmethod
@@ -29,6 +30,7 @@
     def tearDown(cls):
         pass
-    
-ptc.setupPloneSite(extension_profiles=['quintagroup.captcha.core:default',])
+
+ptc.setupPloneSite(extension_profiles=['quintagroup.captcha.core:default', ])
+
 
 class FormlibCaptchaTestCase(ptc.FunctionalTestCase):
@@ -44,5 +46,5 @@
         self.hashkey = self.portal.getCaptcha()
         decrypted = decrypt(captcha_key, self.hashkey)
-        self.captcha_word = getWord(int(parseKey(decrypted)['key'])-1 )
+        self.captcha_word = getWord(int(parseKey(decrypted)['key']) - 1)
 
 
@@ -54,6 +56,6 @@
             'README.txt', package='quintagroup.formlib.captcha',
             test_class=FormlibCaptchaTestCase,
-            optionflags=doctest.REPORT_ONLY_FIRST_FAILURE | doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS),
-            
+            optionflags=doctest.REPORT_ONLY_FIRST_FAILURE | \
+                        doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS),
         ])
 
Index: /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/tests/test_unittests.py
===================================================================
--- /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/tests/test_unittests.py	(revision 3120)
+++ /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/tests/test_unittests.py	(revision 3121)
@@ -21,4 +21,5 @@
 from quintagroup.formlib.captcha import CaptchaWidget
 
+
 @onsetup
 def setup_product():
@@ -31,5 +32,5 @@
 
 setup_product()
-ptc.setupPloneSite(extension_profiles=['quintagroup.captcha.core:default',])
+ptc.setupPloneSite(extension_profiles=['quintagroup.captcha.core:default', ])
 
 
@@ -79,5 +80,5 @@
         FIELDTAG = '<input\s+[^>]*type=\"text\"\s*[^>]*>'
         self.assertEqual(re.search(FIELDTAG, self.html) is not None, True)
-        
+
 
 class TestCaptchaWidgetToField(ptc.PloneTestCase):
@@ -101,12 +102,13 @@
     def testSubmitRightCaptcha(self):
         decrypted = decrypt(self.captcha_key, self.hashkey)
-        key = getWord(int(parseKey(decrypted)['key'])-1 )
+        key = getWord(int(parseKey(decrypted)['key']) - 1)
         try:
             res = self.widget._toFieldValue(key)
         except ConversionError, e:
-            self.fail("Rised unexpected %s error on right captcha submit" % e.doc())
+            self.fail("Rised unexpected %s error on right captcha submit" % \
+                      e.doc())
         else:
             self.assertEqual(res, key)
-        
+
     def testSubmitWrongCaptcha(self):
         try:
@@ -119,5 +121,5 @@
     def testSubmitRightCaptchaTwice(self):
         decrypted = decrypt(self.captcha_key, self.hashkey)
-        key = getWord(int(parseKey(decrypted)['key'])-1 )
+        key = getWord(int(parseKey(decrypted)['key']) - 1)
         self.widget._toFieldValue(key)
         try:
Index: /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/widget.py
===================================================================
--- /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/widget.py	(revision 3120)
+++ /quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/widget.py	(revision 3121)
@@ -23,4 +23,5 @@
 logger = logging.getLogger('quintagroup.formlib.captcha')
 
+
 class CaptchaWidget(ASCIIWidget):
 
@@ -42,5 +43,5 @@
 
         site = self.get_site()
-        portal_url = getToolByName(site , 'portal_url')()
+        portal_url = getToolByName(site, 'portal_url')()
         key = site.getCaptcha()
 
@@ -52,10 +53,12 @@
         return u"""<input type="hidden" value="%s" name="%shashkey" />
                    %s
-                   <img src="%s/getCaptchaImage/%s" alt="Enter the word"/>""" % (key,
-                                                                                 prefix,
-                                                                                 renderElement(self.tag, **kwargs),
-                                                                                 portal_url,
-                                                                                 key)
-         
+                   <img src="%s/getCaptchaImage/%s"
+                        alt="Enter the word"/>""" % (key,
+                                                     prefix,
+                                                     renderElement(self.tag,
+                                                                   **kwargs),
+                                                     portal_url,
+                                                     key)
+
     def _toFieldValue(self, input):
         # Verify the user input against the captcha
@@ -64,5 +67,5 @@
         site = self.get_site()
         captcha_type = site.getCaptchaType()
-        
+
         # validate captcha input
         if input and captcha_type in ['static', 'dynamic']:
@@ -72,12 +75,12 @@
             else:
                 prefix = ''
-            
+
             hashkey = self.request.get('%shashkey' % prefix, '')
             decrypted_key = decrypt(site.captcha_key, hashkey)
             parsed_key = parseKey(decrypted_key)
-            
+
             index = parsed_key['key']
             date = parsed_key['date']
-            
+
             if captcha_type == 'static':
                 img = getattr(site, '%s.jpg' % index)
@@ -87,10 +90,11 @@
                 enc = input
                 solution = getWord(int(index))
-            
+
             captcha_tool = getToolByName(site, 'portal_captchas')
-            if (enc != solution) or (captcha_tool.has_key(decrypted_key)) or (DateTime().timeTime() - float(date) > 3600):
+            if (enc != solution) or (decrypted_key in captcha_tool) or \
+               (DateTime().timeTime() - float(date) > 3600):
                 raise ConversionError(_(u'Please re-enter validation code.'))
             else:
                 captcha_tool.addExpiredKey(decrypted_key)
-        
+
         return super(CaptchaWidget, self)._toFieldValue(input)
Index: /quintagroup.formlib.captcha/trunk/setup.py
===================================================================
--- /quintagroup.formlib.captcha/trunk/setup.py	(revision 3120)
+++ /quintagroup.formlib.captcha/trunk/setup.py	(revision 3121)
@@ -6,8 +6,8 @@
 setup(name='quintagroup.formlib.captcha',
       version=version,
-      description="Captcha field for formlib based on quintagroup.captcha.core package",
+      description="Captcha field for formlib based on "
+                  "quintagroup.captcha.core package",
       long_description=open("README.txt").read() + "\n" +
                        open(os.path.join("docs", "HISTORY.txt")).read(),
-      # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers
       classifiers=[
         "Framework :: Plone",
