Index: /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/Extensions/Install.py
===================================================================
--- /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/Extensions/Install.py	(revision 3159)
+++ /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/Extensions/Install.py	(revision 3160)
@@ -2,4 +2,5 @@
 from Products.CMFCore.utils import getToolByName
 REQUIRED = 'quintagroup.captcha.core'
+
 
 def install(self):
@@ -13,9 +14,12 @@
     # install plonecaptchas
     gs = getToolByName(self, 'portal_setup')
-    gs.runAllImportStepsFromProfile('profile-quintagroup.plonecaptchas:default')
+    profile = 'profile-quintagroup.plonecaptchas:default'
+    gs.runAllImportStepsFromProfile(profile)
     transaction.savepoint()
+
 
 def uninstall(self):
     portal_setup = getToolByName(self, 'portal_setup')
-    portal_setup.runAllImportStepsFromProfile('profile-quintagroup.plonecaptchas:uninstall', purge_old=False)
+    profile = 'profile-quintagroup.plonecaptchas:uninstall'
+    portal_setup.runAllImportStepsFromProfile(profile, purge_old=False)
     transaction.savepoint()
Index: /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/Extensions/__init__.py
===================================================================
--- /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/Extensions/__init__.py	(revision 3159)
+++ /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/Extensions/__init__.py	(revision 3160)
Index: /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/__init__.py
===================================================================
--- /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/__init__.py	(revision 3159)
+++ /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/__init__.py	(revision 3160)
@@ -3,10 +3,12 @@
 from AccessControl import ModuleSecurityInfo
 
-ProductMessageFactory = MessageFactory('quintagroup.plonecaptchas')
-ModuleSecurityInfo('quintagroup.plonecaptchas').declarePublic("ProductMessageFactory")
+product = 'quintagroup.plonecaptchas'
+ProductMessageFactory = MessageFactory(product)
+ModuleSecurityInfo(product).declarePublic("ProductMessageFactory")
 
 #from quintagroup.plonecaptchas import config
 #allow_module('quintagroup.plonecaptchas.config')
 
+
 def initialize(context):
     pass
Index: /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/browser/register.py
===================================================================
--- /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/browser/register.py	(revision 3159)
+++ /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/browser/register.py	(revision 3160)
@@ -8,8 +8,10 @@
 from quintagroup.plonecaptchas import ProductMessageFactory as _
 
+
 class CaptchaSchema(Interface):
     captcha = Captcha(
         title=_(u'Type the code'),
         description=_(u'Type the code from the picture shown below.'))
+
 
 class CaptchaRegistrationForm(RegistrationForm):
@@ -27,3 +29,2 @@
             ffields["captcha"].custom_widget = CaptchaWidget
         return ffields
-
Index: /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/interfaces.py
===================================================================
--- /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/interfaces.py	(revision 3159)
+++ /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/interfaces.py	(revision 3160)
@@ -1,3 +1,4 @@
 from plone.theme.interfaces import IDefaultPloneLayer
+
 
 class IQGPloneCaptchas(IDefaultPloneLayer):
Index: /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/setuphandlers.py
===================================================================
--- /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/setuphandlers.py	(revision 3159)
+++ /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/setuphandlers.py	(revision 3160)
@@ -3,4 +3,5 @@
 
 logger = logging.getLogger('quintagroup.plonecaptchas')
+
 
 def removeBrowserLayer(site):
@@ -10,5 +11,5 @@
     from plone.browserlayer.interfaces import ILocalBrowserLayerType
 
-    name="quintagroup.plonecaptchas"
+    name = "quintagroup.plonecaptchas"
     site = getSiteManager(site)
     registeredLayers = [r.name for r in site.registeredUtilities()
@@ -17,4 +18,5 @@
         unregister_layer(name, site_manager=site)
         logger.log(logging.INFO, "Unregistered \"%s\" browser layer." % name)
+
 
 def uninstall(context):
Index: /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/tests/base.py
===================================================================
--- /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/tests/base.py	(revision 3159)
+++ /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/tests/base.py	(revision 3160)
@@ -15,5 +15,6 @@
 CAPTCHA_KEY = 'captcha_key'
 CAPTCHAS_COUNT = 165
-LAYERS = ['captchas_discussion', 'captchas_sendto_form', "captchas_contact_info"]
+LAYERS = ['captchas_discussion', 'captchas_sendto_form',
+          'captchas_contact_info']
 
 TOOL_ICON = 'skins/plone_captchas/tool.gif'
@@ -26,4 +27,5 @@
 
 ptc.setupPloneSite()
+
 
 class NotInstalled(PloneSite):
@@ -71,4 +73,5 @@
     layer = Installed
 
+
 class TestCaseNotInstalled(ptc.PloneTestCase):
     layer = NotInstalled
@@ -78,4 +81,5 @@
     layer = Installed
 
+
 class FunctionalTestCaseNotInstalled(ptc.FunctionalTestCase):
     layer = NotInstalled
Index: /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/tests/testForms.py
===================================================================
--- /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/tests/testForms.py	(revision 3159)
+++ /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/tests/testForms.py	(revision 3160)
@@ -17,5 +17,5 @@
 from plone.app.controlpanel.security import ISecuritySchema
 
-# BBB for plone v<3.1, where plone.protect not used yet 
+# BBB for plone v<3.1, where plone.protect not used yet
 PROTECT_SUPPORT = True
 try:
@@ -30,4 +30,5 @@
 testPatch()
 
+
 class TestFormMixin(FunctionalTestCase):
 
@@ -41,5 +42,5 @@
         addTestLayer(self)
         # Prepare form data
-        self.basic_auth = ':'.join((portal_owner,default_password))
+        self.basic_auth = ':'.join((portal_owner, default_password))
         self.form_url = ''
         self.form_method = "POST"
@@ -55,5 +56,5 @@
         raise NotImplementedError(
             "getFormData not implemented")
-        
+
     def publishForm(self):
         stdin_data = None
@@ -82,11 +83,11 @@
         open("/tmp/test.%s.html" % name, "w").write(response)
         logs = self.portal.error_log.getLogEntries()
-        if len(logs)>0:
+        if len(logs) > 0:
             i = 0
             while logs:
                 l = logs.pop()
-                i+=1                
-                open("/tmp/test.%s.error.%d.html" % (l,i),"w").write(l["tb_html"])
-            import pdb;pdb.set_trace()
+                i += 1
+                open("/tmp/test.%s.error.%d.html" % (l["id"], i),
+                                                     "w").write(l["tb_html"])
 
     def testImage(self):
@@ -94,17 +95,19 @@
         self.form_method = "GET"
         response = self.publishForm().getBody()
-        patt = re.compile(IMAGE_PATT  % self.portal.absolute_url())
+        patt = re.compile(IMAGE_PATT % self.portal.absolute_url())
         match_obj = patt.search(response)
         self.elog("image", response)
         img_url = match_obj.group(1)
 
-        content_type = self.publish('/plone' + img_url).getHeader('content-type')
+        content_type = self.publish(
+                            '/plone' + img_url).getHeader('content-type')
         self.assertTrue(content_type.startswith('image'),
             "Wrong captcha image content type")
 
     def testSubmitRightCaptcha(self):
-        key = getWord(int(parseKey(decrypt(self.captcha_key, self.hashkey))['key'])-1)
+        key = getWord(int(parseKey(decrypt(self.captcha_key,
+                                           self.hashkey))['key']) - 1)
         self.form_data[self.formkey_key] = key
-        
+
         response = self.publishForm().getBody()
         self.elog("right", response)
@@ -118,5 +121,6 @@
 
     def testSubmitRightCaptchaTwice(self):
-        key = getWord(int(parseKey(decrypt(self.captcha_key, self.hashkey))['key'])-1)
+        key = getWord(int(parseKey(decrypt(self.captcha_key,
+                                           self.hashkey))['key']) - 1)
         self.form_data[self.formkey_key] = key
 
@@ -135,12 +139,12 @@
         self.portal['index_html'].allowDiscussion(True)
         self.form_url = '/index_html/discussion_reply_form'
-        
-    def getFormData(self):
-        return {'form.submitted' : '1',
+
+    def getFormData(self):
+        return {'form.submitted': '1',
                 'subject': 'testing',
                 'Creator': portal_owner,
                 'body_text': 'Text in Comment',
                 'discussion_reply:method': 'Save',
-                'form.button.form_submit' : 'Save'}
+                'form.button.form_submit': 'Save'}
 
 
@@ -160,10 +164,10 @@
 
     def getFormData(self):
-        return {"form.fullname" : "Tester",
-                "form.username" : "tester",
-                "form.email" : "tester@test.com",
-                "form.password" : "123456",
-                "form.password_ctl" : "123456",
-                'form.actions.register' : 'Register'}
+        return {"form.fullname": "Tester",
+                "form.username": "tester",
+                "form.email": "tester@test.com",
+                "form.password": "123456",
+                "form.password_ctl": "123456",
+                'form.actions.register': 'Register'}
 
 
@@ -175,15 +179,17 @@
         self.portal['index_html'].allowDiscussion(True)
         self.form_url = '/index_html/sendto_form'
-        
-    def getFormData(self):
-        return {'form.submitted' : '1',
-                "send_to_address" : "recipient@test.com",
-                "send_from_address" : "sender@test.com",
+
+    def getFormData(self):
+        return {'form.submitted': '1',
+                "send_to_address": "recipient@test.com",
+                "send_from_address": "sender@test.com",
                 'comment': 'Text in Comment',
-                'form.button.Send' : 'Save'}
+                'form.button.Send': 'Save'}
+
 
 def send_patch(self, *args, **kwargs):
     """This patch prevent breakage on sending."""
 
+
 class TestContactInfo(TestFormMixin):
 
@@ -191,5 +197,5 @@
         TestFormMixin.afterSetUp(self)
         # preparation to form correct working
-        self.portal._updateProperty('email_from_address','manager@test.com')
+        self.portal._updateProperty('email_from_address', 'manager@test.com')
         self.logout()
         self.form_url = '/contact-info'
@@ -201,10 +207,10 @@
 
     def getFormData(self):
-        return {'form.submitted' : '1',
-                "sender_fullname" : "tester",
-                "sender_from_address" : "sender@test.com",
+        return {'form.submitted': '1',
+                "sender_fullname": "tester",
+                "sender_from_address": "sender@test.com",
                 'subject': 'Subject',
                 'message': 'Message',
-                'form.button.Send' : 'Save'}
+                'form.button.Send': 'Save'}
 
 
Index: /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/tests/testInstallation.py
===================================================================
--- /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/tests/testInstallation.py	(revision 3159)
+++ /quintagroup.plonecaptchas/branches/plone4/quintagroup/plonecaptchas/tests/testInstallation.py	(revision 3160)
@@ -26,7 +26,8 @@
             for layer in LAYERS:
                 self.assert_(layer.split('/')[0] in self.skins.objectIds(),
-                    '%s directory view not found in portal_skins after installation' % layer)
+                             '%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))
+                             '%s layer not found in %s' % (PRODUCT_NAME, skin))
 
     def testBrowserLayerRegistration(self):
@@ -40,5 +41,6 @@
         # Mark request with IQGPloneCaptchas browser layer interface
         alsoProvides(self.portal.REQUEST, IQGPloneCaptchas)
-        register = queryMultiAdapter((self.portal, self.portal.REQUEST), name="register")
+        register = queryMultiAdapter((self.portal, self.portal.REQUEST),
+                                     name="register")
         self.assertEqual(isinstance(register, CaptchaRegistrationForm), True)
 
@@ -60,8 +62,11 @@
             path = map(str.strip, path.split(','))
             for layer in LAYERS:
-                self.assertTrue(not layer.split('/')[0] in self.skins.objectIds(),
-                    '%s directory view found in portal_skins after uninstallation' % layer)
+                self.assertTrue(
+                        not layer.split('/')[0] in self.skins.objectIds(),
+                        '%s directory view found in portal_skins '\
+                        'after uninstallation' % layer)
                 self.assert_(not layer in path,
-                    '%s layer found in %s skin after uninstallation' % (layer, skin))
+                    '%s layer found in %s skin after uninstallation' % (layer,
+                                                                        skin))
 
     def testBrowserLayerUnregistration(self):
@@ -70,10 +75,13 @@
         registeredLayers = [r.name for r in site.registeredUtilities()
                             if r.provided == ILocalBrowserLayerType]
-        self.assertNotEqual("quintagroup.plonecaptchas" in registeredLayers, True)
+        self.assertNotEqual("quintagroup.plonecaptchas" in registeredLayers,
+                            True)
 
     def testRegisterFormOverriden(self):
         # Mark request with IQGPloneCaptchas browser layer interface
-        register = queryMultiAdapter((self.portal, self.portal.REQUEST), name="register")
-        self.assertNotEqual(isinstance(register, CaptchaRegistrationForm), True)
+        register = queryMultiAdapter((self.portal, self.portal.REQUEST),
+                                     name="register")
+        self.assertNotEqual(isinstance(register, CaptchaRegistrationForm),
+                            True)
 
 
Index: /quintagroup.plonecaptchas/branches/plone4/setup.py
===================================================================
--- /quintagroup.plonecaptchas/branches/plone4/setup.py	(revision 3159)
+++ /quintagroup.plonecaptchas/branches/plone4/setup.py	(revision 3160)
@@ -6,8 +6,9 @@
 setup(name='quintagroup.plonecaptchas',
       version=version,
-      description="quintagroup.plonecaptchas is simple captchas implementation for Plone, designed for validating human input in insecure forms.",
+      description="quintagroup.plonecaptchas is simple captchas "
+                  "implementation for Plone, designed for validating "
+                  "human input in insecure forms.",
       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",
