Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/CaptchaTool.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/CaptchaTool.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/CaptchaTool.py	(revision 3128)
@@ -5,4 +5,5 @@
 from AccessControl import ClassSecurityInfo
 from Products.Transience.Transience import TransientObjectContainer
+
 
 class CaptchaTool(TransientObjectContainer):
@@ -13,8 +14,10 @@
     security.declarePublic('addExpiredKey')
 
-    def __init__(self, id='portal_captchas', title='', timeout_mins=60, addNotification=None,
+    def __init__(self, id='portal_captchas', title='',
+                 timeout_mins=60, addNotification=None,
                  delNotification=None, limit=0, period_secs=60):
-        TransientObjectContainer.__init__(self, id, title, timeout_mins, addNotification,
-                                          delNotification, limit, period_secs)
+        TransientObjectContainer.__init__(self, id, title, timeout_mins,
+                                          addNotification, delNotification,
+                                          limit, period_secs)
 
     def addExpiredKey(self, key):
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/Crypto.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/Crypto.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/Crypto.py	(revision 3128)
@@ -1,6 +1,8 @@
 # xor implementation with PyCrypto interface
+
 
 def new(key):
     return Xor(key)
+
 
 class Xor:
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/Extensions/Install.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/Extensions/Install.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/Extensions/Install.py	(revision 3128)
@@ -2,6 +2,8 @@
 from Products.CMFCore.utils import getToolByName
 
+
 def uninstall(self):
     portal_setup = getToolByName(self, 'portal_setup')
-    portal_setup.runAllImportStepsFromProfile('profile-quintagroup.captcha.core:uninstall', purge_old=False)
+    profile = "profile-quintagroup.captcha.core:uninstall"
+    portal_setup.runAllImportStepsFromProfile(profile, purge_old=False)
     transaction.savepoint()
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/Extensions/__init__.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/Extensions/__init__.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/Extensions/__init__.py	(revision 3128)
@@ -1,1 +1,0 @@
-#
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/__init__.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/__init__.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/__init__.py	(revision 3128)
@@ -7,9 +7,11 @@
 from quintagroup.captcha.core import CaptchaTool
 
-ProductMessageFactory = MessageFactory('quintagroup.captcha.core')
-ModuleSecurityInfo('quintagroup.captcha.core').declarePublic("ProductMessageFactory")
+product = 'quintagroup.captcha.core'
+ProductMessageFactory = MessageFactory(product)
+ModuleSecurityInfo(product).declarePublic("ProductMessageFactory")
 
 allow_module('quintagroup.captcha.core.utils')
 allow_module('quintagroup.captcha.core.config')
+
 
 def initialize(context):
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/encrypt_images.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/encrypt_images.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/encrypt_images.py	(revision 3128)
@@ -1,4 +1,5 @@
 import md5
 import os
+
 
 def encrypt_md5(s):
@@ -12,9 +13,9 @@
     fname = file[:-5]
     hash = md5.new(fname).hexdigest().upper()
-    new_fname = str(index)+'.jpg'
+    new_fname = str(index) + '.jpg'
     metaname = new_fname + '.metadata'
-    meta = open(metaname,'w')
+    meta = open(metaname, 'w')
     meta.write('[default]\n')
-    meta.write('title='+hash)
+    meta.write('title=' + hash)
     meta.close()
     os.rename(file, new_fname)
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/setuphandlers.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/setuphandlers.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/setuphandlers.py	(revision 3128)
@@ -6,4 +6,5 @@
     ALL_LAYERS, PROPERTY_SHEET
 
+
 def generateKey(length):
     key = ''
@@ -11,4 +12,5 @@
         key += str(randint(0, 9))
     return key
+
 
 def setupVarious(context):
@@ -24,4 +26,5 @@
     else:
         site._setProperty(CAPTCHA_KEY, value, 'string')
+
 
 def uninstall(context):
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/skins/captcha_core/dynamic/getCaptcha.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/skins/captcha_core/dynamic/getCaptcha.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/skins/captcha_core/dynamic/getCaptcha.py	(revision 3128)
@@ -12,5 +12,5 @@
 # *randint* return random integer in range [a, b],
 # including *both* end points.
-key = formKey(randint(0, getCaptchasCount(True)-1))
+key = formKey(randint(0, getCaptchasCount(True) - 1))
 encrypted_key = encrypt(context.captcha_key, key)
 
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/skins/captcha_core/getCaptchaType.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/skins/captcha_core/getCaptchaType.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/skins/captcha_core/getCaptchaType.py	(revision 3128)
@@ -16,5 +16,5 @@
 default_skin = skinsTool.getDefaultSkin()
 path = skinsTool.getSkinPath(default_skin)
-path = map( string.strip, string.split( path,',' ) )
+path = map(string.strip, string.split(path, ','))
 
 if LAYER_STATIC_CAPTCHAS in path:
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/base.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/base.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/base.py	(revision 3128)
@@ -24,4 +24,6 @@
 burn
 """
+
+
 def testPatch():
     # PATCH dictionary for captcha testing
@@ -32,4 +34,5 @@
     utils.CAPTCHAS_COUNT = len(utils.basic_english.words.split())
     # END OF PATCH
+
 
 @onsetup
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testConfiglet.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testConfiglet.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testConfiglet.py	(revision 3128)
@@ -1,4 +1,6 @@
-import re, string
+import re
+import string
 from base import *
+
 
 class TestConfiglet(ptc.FunctionalTestCase):
@@ -6,8 +8,8 @@
     def afterSetUp(self):
         self.sp = self.portal.portal_properties.site_properties
-        self.basic_auth = ':'.join((portal_owner,default_password))
+        self.basic_auth = ':'.join((portal_owner, default_password))
         self.loginAsPortalOwner()
         self.addProduct(PRODUCT_NAME)
-        
+
         self.capprops = self.portal.portal_properties[PROPERTY_SHEET]
         self.save_url = self.portal.id + \
@@ -20,5 +22,5 @@
         for skin in skins.getSkinSelections():
             path = skins.getSkinPath(skin)
-            path = map( string.strip, string.split( path,',' ))
+            path = map(string.strip, string.split(path, ','))
             if not layer in path:
                 return False
@@ -29,5 +31,5 @@
         self.publish(self.save_url + '&static_captchas=static',
                      self.basic_auth)
-        
+
         self.assertTrue(self.layerInSkins(LAYER_STATIC_CAPTCHAS),
             "No '%s' skin layer in some skins" % LAYER_STATIC_CAPTCHAS)
@@ -36,5 +38,5 @@
         res = self.publish(self.save_url + '&static_captchas=dynamic',
                      self.basic_auth).getBody()
-        
+
         self.assertTrue(self.layerInSkins(LAYER_DYNAMIC_CAPTCHAS),
             "No '%s' skin layer in some skins" % LAYER_DYNAMIC_CAPTCHAS)
@@ -99,14 +101,16 @@
         self.loginAsPortalOwner()
         self.addProduct(PRODUCT_NAME)
-        self.view = self.publish(self.portal.id+'/prefs_captchas_setup_form',
-                                 portal_owner+":"+default_password).getBody()
- 
+        captcha_pref_path = self.portal.id + '/prefs_captchas_setup_form'
+        basic_auth = portal_owner + ":" + default_password
+        self.view = self.publish(captcha_pref_path, basic_auth).getBody()
+
     def matchinput(self, name):
         return re.match('.*<input\s+[^\>]*name=\"%s\"[^>]*>' % name,
-                        self.view, re.I|re.S)
+                        self.view, re.I | re.S)
 
     def test_basic_form(self):
-        form = re.match('.*<form\s+[^\>]*action=\"[^\"]*?prefs_captchas_setup_form\"[^>]*>',
-                        self.view, re.I|re.S)
+        reg_expr = '.*<form\s+[^\>]*action=\"[^\"]*?'\
+                   'prefs_captchas_setup_form\"[^>]*>'
+        form = re.match(reg_expr, self.view, re.I | re.S)
         self.assertNotEqual(form, None,
             "No 'Plone Captchas Setup' form present on the configlet view")
@@ -122,5 +126,5 @@
             self.assertNotEqual(self.matchinput(param), None,
                 "'%s' form element absence on the configlet form" % param)
-        
+
 
 def test_suite():
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testDynamic.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testDynamic.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testDynamic.py	(revision 3128)
@@ -12,5 +12,5 @@
     from PIL import ImageFont
     fontspath = abspath(dirname(dirname(__file__))) + '/data/fonts/vera/'
-    font = ImageFont.truetype(fontspath+'VeraBd.ttf', 27)
+    font = ImageFont.truetype(fontspath + 'VeraBd.ttf', 27)
 except ImportError:
     DYNAMIC_WORKABLE = False
@@ -24,5 +24,5 @@
         for skin in skins.getSkinSelections():
             path = skins.getSkinPath(skin)
-            path = map( string.strip, string.split( path,',' ))
+            path = map(string.strip, string.split(path, ','))
             try:
                 i = path.index(LAYER_STATIC_CAPTCHAS)
@@ -31,11 +31,11 @@
             except ValueError:
                 pass
-            path = string.join( path, ', ' )
-            skins.addSkinSelection( skin, path )
+            path = string.join(path, ', ')
+            skins.addSkinSelection(skin, path)
             self._refreshSkinData()
 
 
 class TestPIL(unittest.TestCase):
-    
+
     def testPILImageFont(self):
         if not DYNAMIC_WORKABLE:
@@ -69,5 +69,6 @@
         # index start from 0 and lower or equals to captchas count
         index = int(parsed_key['key'])
-        self.assertTrue(index >= 0 and index <= len(utils.basic_english.words.split()))
+        words = utils.basic_english.words.split()
+        self.assertTrue(index >= 0 and index <= len(words))
         # encrypted key must be equals to word from the dictionary,
         # under index position and must be not empty string
@@ -76,10 +77,10 @@
     def test_GetImage(self):
         # getCaptchaImage function must return image coded in hashkey same to
-        # image get by 'key' after parsing decrypted key 
+        # image get by 'key' after parsing decrypted key
         decrypted_key = decrypt(self.captcha_key, self.hashkey)
         parsed_key = parseKey(decrypted_key)
 
         img_html = self.publish(
-            self.portal.absolute_url(1)+"/getCaptchaImage/%s" % self.hashkey)
+            self.portal.absolute_url(1) + "/getCaptchaImage/%s" % self.hashkey)
 
         img_ctype = img_html.getHeader('content-type')
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testInstallation.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testInstallation.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testInstallation.py	(revision 3128)
@@ -1,3 +1,4 @@
 from base import *
+
 
 class TestInstallation(ptc.FunctionalTestCase):
@@ -15,5 +16,6 @@
     def testPropertysheetInstall(self):
         pp = getToolByName(self.portal, 'portal_properties')
-        self.assert_(PROPERTY_SHEET in pp.objectIds(), 'Property sheet isn\'t found')
+        msg = 'Property sheet isn\'t found'
+        self.assert_(PROPERTY_SHEET in pp.objectIds(), msg)
 
     def testPropertysheetUninstall(self):
@@ -24,10 +26,18 @@
 
     def testConfigletInstall(self):
-        self.assert_(CONFIGLET_ID in [a.getId() for a in self.cp.listActions()], 'Configlet not found')
+        list_ids = []
+        for action in self.cp.listActions():
+            list_ids.append(action.getId())
+        self.assert_(CONFIGLET_ID in list_ids, 'Configlet not found')
 
     def testConfigletUninstall(self):
         self.qi.uninstallProducts([PRODUCT_NAME])
-        self.assertNotEqual(self.qi.isProductInstalled(PRODUCT_NAME), True,'%s is already installed' % PRODUCT_NAME)
-        self.assert_(not CONFIGLET_ID in [a.getId() for a in self.cp.listActions()], 'Configlet found after uninstallation')
+        self.assertNotEqual(self.qi.isProductInstalled(PRODUCT_NAME), True,
+                            '%s is already installed' % PRODUCT_NAME)
+        list_ids = []
+        for action in self.cp.listActions():
+            list_ids.append(action.getId())
+        msg = 'Configlet found after uninstallation'
+        self.assert_(not CONFIGLET_ID in list_ids, msg)
 
     def testSkinsInstall(self):
@@ -38,10 +48,14 @@
             path = map(str.strip, path.split(','))
             for layer in layers:
-                self.assert_(layer.split('/')[0] in skinstool.objectIds(), '%s directory view not found in portal_skins after installation' % layer)
-                self.assert_(layer in path, '%s layer not found in %s' % (PRODUCT_NAME, skin))
+                msg = '%s directory view not found in'\
+                      'portal_skins after installation' % layer
+                self.assert_(layer.split('/')[0] in skinstool.objectIds(), msg)
+                msg = '%s layer not found in %s' % (PRODUCT_NAME, skin)
+                self.assert_(layer in path, msg)
 
     def testSkinsUninstall(self):
         self.qi.uninstallProducts([PRODUCT_NAME])
-        self.assertNotEqual(self.qi.isProductInstalled(PRODUCT_NAME), True,'%s is already installed' % PRODUCT_NAME)
+        self.assertNotEqual(self.qi.isProductInstalled(PRODUCT_NAME), True,
+                            '%s is already installed' % PRODUCT_NAME)
         skinstool = self.st
         layers = self.getLayers()
@@ -50,6 +64,11 @@
             path = map(str.strip, path.split(','))
             for layer in layers:
-                self.assert_(not layer.split('/')[0] in skinstool.objectIds(), '%s directory view found in portal_skins after uninstallation' % layer)
-                self.assert_(not layer in path, '%s layer found in %s after uninstallation' % (layer, skin))
+                msg = '%s directory view found in'\
+                      'portal_skins after uninstallation' % layer
+                skins_tool_ids = skinstool.objectIds()
+                self.assert_(not layer.split('/')[0] in skins_tool_ids, msg)
+                msg = '%s layer found in'\
+                      '%s after uninstallation' % (layer, skin)
+                self.assert_(not layer in path, msg)
 
     def testToolInstall(self):
@@ -58,5 +77,5 @@
     def testToolUninstall(self):
         self.qi.uninstallProducts([PRODUCT_NAME])
-        self.assertNotEqual(self.qi.isProductInstalled(PRODUCT_NAME), True, 
+        self.assertNotEqual(self.qi.isProductInstalled(PRODUCT_NAME), True,
             '%s is already installed' % PRODUCT_NAME)
         self.assert_(not TOOL_ID in self.portal.objectIds())
@@ -69,4 +88,5 @@
         self.assert_(not self.portal.hasProperty(CAPTCHA_KEY))
 
+
 def test_suite():
     suite = unittest.TestSuite()
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testStatic.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testStatic.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testStatic.py	(revision 3128)
@@ -4,4 +4,5 @@
 from DateTime import DateTime
 from Products.CMFFormController.ControllerState import ControllerState
+
 
 class TestStatic(ptc.FunctionalTestCase):
@@ -19,5 +20,5 @@
         for skin in self.skins.getSkinSelections():
             path = self.skins.getSkinPath(skin)
-            path = map( string.strip, string.split( path,',' ))
+            path = map(string.strip, string.split(path, ','))
             self.assertTrue(LAYER_STATIC_CAPTCHAS in path)
 
@@ -26,7 +27,7 @@
         static = self.skins.restrictedTraverse('captchas')
         static_ids = static.objectIds()
-        for i in range(1, CAPTCHAS_COUNT+1):
+        for i in range(1, CAPTCHAS_COUNT + 1):
             self.assertTrue("%s.jpg" % i in static_ids,
-                            "No %s.jpg in static, %s" % (i,static_ids))
+                            "No %s.jpg in static, %s" % (i, static_ids))
 
     def test_GetCaptcha_Date(self):
@@ -45,5 +46,5 @@
         self.assertTrue(index >= 1 and index <= CAPTCHAS_COUNT)
         # encrypted key must be equals to title of the image
-        key = getWord( index-1 )
+        key = getWord(index - 1)
         img = getattr(self.portal, '%s.jpg' % index)
         self.assertTrue(encrypt1(key) == img.title)
@@ -51,16 +52,18 @@
     def test_GetImage(self):
         # getCaptchaImage function must return image coded in hashkey same to
-        # image get by 'key' after parsing decrypted key 
+        # image get by 'key' after parsing decrypted key
         req, resp = self.app.REQUEST, self.app.REQUEST.RESPONSE
         decrypted_key = decrypt(self.captcha_key, self.hashkey)
         parsed_key = parseKey(decrypted_key)
-        img = self.portal.restrictedTraverse(parsed_key['key']+'.jpg')
+        img = self.portal.restrictedTraverse(parsed_key['key'] + '.jpg')
         img_html = img.index_html(req, resp)
 
-        obj_html = self.publish(
-            self.portal.absolute_url(1)+"/getCaptchaImage/%s" % self.hashkey).getBody()
-        self.assertTrue(obj_html == img_html, "Image get by getCaptchaImage script " \
-            "is differ from image get by index (after parsing decrypted key)")
-        
+        portal = self.portal.absolute_url(1)
+        captcha_path = portal + "/getCaptchaImage/%s" % self.hashkey
+        obj_html = self.publish(captcha_path).getBody()
+        msg = "Image get by getCaptchaImage script is differ from"\
+              "image get by index (after parsing decrypted key)"
+        self.assertTrue(obj_html == img_html, msg)
+
 
 class TestStaticValidator(ptc.PloneTestCase):
@@ -80,20 +83,26 @@
     def testGoodData(self):
         hashkey = self.portal.getCaptcha()
-        key = getWord(int(parseKey(decrypt(self.captcha_key, hashkey))['key'])-1 )
+        decrypted_key = decrypt(self.captcha_key, hashkey)
+        key = getWord(int(parseKey(decrypted_key)['key']) - 1)
         self.req.form['hashkey'] = hashkey
-        self.req.form['key'] = key+'1'
+        self.req.form['key'] = key + '1'
 
-        cstate = self.pfc.validate(self.dummycs, self.req, ['captcha_validator',])
-        self.assertTrue(cstate.getErrors()['key'] == 'Please re-enter validation code.',
+        cstate = self.pfc.validate(self.dummycs, self.req,
+                                   ['captcha_validator', ])
+        error_msg = 'Please re-enter validation code.'
+        self.assertTrue(cstate.getErrors()['key'] == error_msg,
                         "Static captcha validator validate wrong key")
 
     def testBadKey(self):
         hashkey = self.portal.getCaptcha()
-        key = getWord(int(parseKey(decrypt(self.captcha_key, hashkey))['key'])-1 )
+        decrypted_key = decrypt(self.captcha_key, hashkey)
+        key = getWord(int(parseKey(decrypted_key)['key']) - 1)
         self.req.form['hashkey'] = hashkey
         self.req.form['key'] = 'bad key'
-        
-        cstate = self.pfc.validate(self.dummycs, self.req, ['captcha_validator',])
-        self.assertTrue(cstate.getErrors()['key'] == 'Please re-enter validation code.',
+
+        cstate = self.pfc.validate(self.dummycs, self.req,
+                                   ['captcha_validator', ])
+        error_msg = 'Please re-enter validation code.'
+        self.assertTrue(cstate.getErrors()['key'] == error_msg,
                         "Static captcha validator validate wrong key")
 
@@ -103,13 +112,17 @@
         now = DateTime().timeTime()
         DateTime.timeTime = lambda s: now - float(3601)
-        
+
         hashkey = self.portal.getCaptcha()
-        key = getWord(int(parseKey(decrypt(self.captcha_key, hashkey))['key'])-1 )
+
+        decrypted_key = decrypt(self.captcha_key, hashkey)
+        key = getWord(int(parseKey(decrypted_key)['key']) - 1)
         self.req.form['hashkey'] = hashkey
         self.req.form['key'] = key
         # Return original Date
         DateTime.timeTime = origDTTT
-        cstate = self.pfc.validate(self.dummycs, self.req, ['captcha_validator',])
-        self.assertTrue(cstate.getErrors()['key'] == 'Please re-enter validation code.',
+        cstate = self.pfc.validate(self.dummycs, self.req,
+                                   ['captcha_validator', ])
+        error_msg = 'Please re-enter validation code.'
+        self.assertTrue(cstate.getErrors()['key'] == error_msg,
                         "Static captcha validator validate wrong key")
 
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testWidget.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testWidget.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testWidget.py	(revision 3128)
@@ -12,4 +12,5 @@
 testPatch()
 
+
 def addTestLayer(self):
     # Install test_captcha skin layer
@@ -19,5 +20,5 @@
     skinName = skins.getDefaultSkin()
     paths = map(string.strip, skins.getSkinPath(skinName).split(','))
-    paths.insert(paths.index('custom')+1, 'test_captcha')
+    paths.insert(paths.index('custom') + 1, 'test_captcha')
     skins.addSkinSelection(skinName, ','.join(paths))
     self._refreshSkinData()
@@ -34,26 +35,31 @@
         self.absolute_url = self.portal['index_html'].absolute_url_path()
 
-        self.basic_auth = ':'.join((portal_owner,default_password))
+        self.basic_auth = ':'.join((portal_owner, default_password))
         self.captcha_key = self.portal.captcha_key
 
     def testImage(self):
         path = '%s/test_form' % self.absolute_url
-        response = self.publish(path, self.basic_auth, request_method='GET').getBody()
+        response = self.publish(path, self.basic_auth,
+                                request_method='GET').getBody()
         patt = re.compile(IMAGE_PATT % self.portal.absolute_url())
         match_obj = patt.search(response)
 
         img_url = match_obj.group(1)
-        content_type = self.publish('/plone' + img_url, self.basic_auth).getHeader('content-type')
+        res = self.publish('/plone' + img_url, self.basic_auth)
+        content_type = res.getHeader('content-type')
         self.assert_(content_type.startswith('image'))
 
     def testSubmitRightCaptcha(self):
         hashkey = self.portal.getCaptcha()
-        # index of word number starts from 1, but index of dictionary starts from 0
-        key = getWord(int(parseKey(decrypt(self.captcha_key, hashkey))['key'])-1 )
+        # index of word number starts from 1,
+        # but index of dictionary starts from 0
+        decrypted_key = decrypt(self.captcha_key, hashkey)
+        key = getWord(int(parseKey(decrypted_key)['key']) - 1)
         parameters = 'form.submitted=1&key=%s' % key
         path = '%s/test_form?%s' % (self.absolute_url, parameters)
         extra = {'hashkey': hashkey,
                  'form.button.Save': 'Save'}
-        response = self.publish(path, self.basic_auth, extra=extra, request_method='GET').getBody()
+        response = self.publish(path, self.basic_auth, extra=extra,
+                                request_method='GET').getBody()
         self.assert_(not NOT_VALID.search(response))
 
@@ -64,16 +70,19 @@
         extra = {'hashkey': hashkey,
                  'form.button.Save': 'Save'}
-        response = self.publish(path, self.basic_auth, extra=extra, request_method='GET').getBody()
+        response = self.publish(path, self.basic_auth, extra=extra,
+                                request_method='GET').getBody()
         self.assert_(NOT_VALID.search(response))
 
     def testSubmitRightCaptchaTwice(self):
         hashkey = self.portal.getCaptcha()
-        key = getWord(int(parseKey(decrypt(self.captcha_key, hashkey))['key'])-1)
-        parameters = 'form.submitted=1&key=%s'%key
-        path = '%s/test_form?%s'%(self.absolute_url, parameters)
+        decrypted_key = decrypt(self.captcha_key, hashkey)
+        key = getWord(int(parseKey(decrypted_key)['key']) - 1)
+        parameters = 'form.submitted=1&key=%s' % key
+        path = '%s/test_form?%s' % (self.absolute_url, parameters)
         extra = {'hashkey': hashkey,
                  'form.button.Save': 'Save'}
         self.publish(path, self.basic_auth, extra=extra, request_method='GET')
-        response = self.publish(path, self.basic_auth, extra=extra, request_method='GET').getBody()
+        response = self.publish(path, self.basic_auth, extra=extra,
+                                request_method='GET').getBody()
 
         self.assert_(NOT_VALID.search(response))
@@ -82,6 +91,7 @@
         # captcha core related issue, described in
         # in http://plone.org/products/plone-comments/issues/5
-        resp = self.publish(self.portal.absolute_url(1)+"/captcha_widget")
+        resp = self.publish(self.portal.absolute_url(1) + "/captcha_widget")
         self.assertEqual(resp.status / 100, 2)
+
 
 def test_suite():
Index: /quintagroup.captcha.core/trunk/quintagroup/captcha/core/utils.py
===================================================================
--- /quintagroup.captcha.core/trunk/quintagroup/captcha/core/utils.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/quintagroup/captcha/core/utils.py	(revision 3128)
@@ -19,9 +19,12 @@
     import Crypto
 
+
 def encrypt1(s):
     return md5.md5(s).hexdigest().upper()
 
+
 def getTransform(x, y, a, p, o):
-    return (math.sin( (y+o[0])*p )*a + x, math.sin( (x+o[1])*p )*a + y)
+    return (math.sin((y + o[0]) * p) * a + x, math.sin((x + o[1]) * p) * a + y)
+
 
 def gen_captcha(**kwargs):
@@ -57,19 +60,21 @@
 
     #select font for captcha text
-    ALL_FONTS=('Bd', 'It', 'MoBI', 'Mono', 'Se', 'BI', 'MoBd', 'MoIt', 'SeBd', '')
+    ALL_FONTS = ('Bd', 'It', 'MoBI', 'Mono', 'Se',
+                 'BI', 'MoBd', 'MoIt', 'SeBd', '')
     rand_font = random.choice(ALL_FONTS)
-    font = ImageFont.truetype(FONT_PATH+'/vera/Vera%s.ttf'%rand_font, fnt_sz)
+    rand_font_path = FONT_PATH + '/vera/Vera%s.ttf' % rand_font
+    font = ImageFont.truetype(rand_font_path, fnt_sz)
     textSize = font.getsize(text)
 
 #------------------------------render   background1 -----------------------
-    image = Image.new('RGB', (textSize[0]+7,textSize[1]+7), bkground)
+    image = Image.new('RGB', (textSize[0] + 7, textSize[1] + 7), bkground)
     image.paste(bkground)
 #------------------------------render       Text2 ------------------------
     draw = ImageDraw.Draw(image)
-    alignment = (random.uniform(0,1), random.uniform(0,1))
+    alignment = (random.uniform(0, 1), random.uniform(0, 1))
     x = int((image.size[0] - textSize[0]) * alignment[0] + 0.5)
     y = int((image.size[1] - textSize[1]) * alignment[1] + 0.5)
 
-    draw.text((x,y), text, font=font, fill=font_color)
+    draw.text((x, y), text, font=font, fill=font_color)
 
 #------------------------------render       Distortion -----------------------
@@ -85,9 +90,9 @@
         yRow = []
         for i in xrange(xPoints):
-            x, y = getTransform(i*r, j*r, amplitude, period, offset)
+            x, y = getTransform(i * r, j * r, amplitude, period, offset)
 
             # Clamp the edges so we don't get black undefined areas
-            x = max(0, min(image.size[0]-1, x))
-            y = max(0, min(image.size[1]-1, y))
+            x = max(0, min(image.size[0] - 1, x))
+            y = max(0, min(image.size[1] - 1, y))
 
             xRow.append(x)
@@ -99,15 +104,15 @@
     # each square between points on the grid
     mesh = []
-    for j in xrange(yPoints-1):
-        for i in xrange(xPoints-1):
+    for j in xrange(yPoints - 1):
+        for i in xrange(xPoints - 1):
             mesh.append((
                 # Destination rectangle
-                (i*r, j*r,
-                 (i+1)*r, (j+1)*r),
+                (i * r, j * r,
+                 (i + 1) * r, (j + 1) * r),
                 # Source quadrilateral
-                (xRows[j  ][i  ], yRows[j  ][i  ],
-                 xRows[j+1][i  ], yRows[j+1][i  ],
-                 xRows[j+1][i+1], yRows[j+1][i+1],
-                 xRows[j  ][i+1], yRows[j  ][i+1]),
+                (xRows[j][i],         yRows[j][i],
+                 xRows[j + 1][i],     yRows[j + 1][i],
+                 xRows[j + 1][i + 1], yRows[j + 1][i + 1],
+                 xRows[j][i + 1],     yRows[j][i + 1]),
                 ))
 
@@ -120,5 +125,5 @@
     size = len(src)
     sys.modules['ImageFile'] = ImageFile
-    return {'src':src, 'size':size}
+    return {'src': src, 'size': size}
 
 
@@ -127,4 +132,5 @@
     return words[index]
 
+
 def getIndex(word):
     words = basic_english.words.split()
@@ -132,6 +138,7 @@
         res = words.index(word)
     except ValueError:
-        res = getLen()+1
+        res = getLen() + 1
     return res
+
 
 def getCaptchasCount(dynamic):
@@ -141,15 +148,19 @@
         return CAPTCHAS_COUNT
 
+
 def formKey(num):
     def normalize(s):
-        return (not len(s)%8 and s) or normalize(s+str(randint(0, 9)))
+        return (not len(s) % 8 and s) or normalize(s + str(randint(0, 9)))
 
-    return normalize('%s_%i_'%(str(DateTime().timeTime()), num))
+    return normalize('%s_%i_' % (str(DateTime().timeTime()), num))
+
 
 def encrypt(key, s):
     return toHex(Crypto.new(key).encrypt(s))
 
+
 def decrypt(key, s):
     return Crypto.new(key).decrypt(toStr(s))
+
 
 def parseKey(s):
@@ -157,5 +168,6 @@
     if ps is None:
         return {'date': '', 'key': ''}
-    return {'date': ps.group(1), 'key':ps.group(2)}
+    return {'date': ps.group(1), 'key': ps.group(2)}
+
 
 def toHex(s):
@@ -164,8 +176,9 @@
         hv = hex(ord(ch)).replace('0x', '')
         if len(hv) == 1:
-            hv = '0'+hv
+            hv = '0' + hv
         lst.append(hv)
 
-    return reduce(lambda x,y:x+y, lst)
+    return reduce(lambda x, y: x + y, lst)
+
 
 def toStr(s):
Index: /quintagroup.captcha.core/trunk/setup.py
===================================================================
--- /quintagroup.captcha.core/trunk/setup.py	(revision 3127)
+++ /quintagroup.captcha.core/trunk/setup.py	(revision 3128)
@@ -9,5 +9,4 @@
       long_description=open("README.txt").read() + "\n" +
                        open(os.path.join("docs", "HISTORY.txt")).read(),
-      # Get more strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
       classifiers=[
         "Framework :: Plone",
