Index: main/waeup.kofa/trunk/src/waeup/kofa/authentication.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/authentication.py	(revision 14668)
+++ main/waeup.kofa/trunk/src/waeup/kofa/authentication.py	(revision 14669)
@@ -30,18 +30,19 @@
 from zope.pluggableauth.plugins.session import SessionCredentialsPlugin
 from zope.pluggableauth.plugins.httpplugins import (
-        HTTPBasicAuthCredentialsPlugin)
+    HTTPBasicAuthCredentialsPlugin)
 from zope.pluggableauth.interfaces import (
-        ICredentialsPlugin, IAuthenticatorPlugin,
-        IAuthenticatedPrincipalFactory, AuthenticatedPrincipalCreated)
+    ICredentialsPlugin, IAuthenticatorPlugin, IAuthenticatedPrincipalFactory,
+    AuthenticatedPrincipalCreated)
 from zope.publisher.interfaces import IRequest
 from zope.password.interfaces import IPasswordManager
 from zope.securitypolicy.principalrole import principalRoleManager
-from waeup.kofa.interfaces import (ILocalRoleSetEvent,
-    IUserAccount, IAuthPluginUtility, IPasswordValidator,
-    IKofaPrincipal, IKofaPrincipalInfo, IKofaPluggable,
-    IBatchProcessor, IGNORE_MARKER, IFailedLoginInfo)
+from waeup.kofa.interfaces import (
+    ILocalRoleSetEvent, IUserAccount, IAuthPluginUtility, IPasswordValidator,
+    IKofaPrincipal, IKofaPrincipalInfo, IKofaPluggable, IBatchProcessor,
+    IGNORE_MARKER, IFailedLoginInfo)
 from waeup.kofa.utils.batching import BatchProcessor
 from waeup.kofa.permissions import get_all_roles
 
+
 def setup_authentication(pau):
     """Set up plugguble authentication utility.
@@ -53,7 +54,7 @@
     """
     pau.credentialsPlugins = (
-            'No Challenge if Authenticated',
-            'xmlrpc-credentials',
-            'credentials')
+        'No Challenge if Authenticated',
+        'xmlrpc-credentials',
+        'credentials')
     pau.authenticatorPlugins = ('users',)
 
@@ -63,4 +64,5 @@
         util.register(pau)
 
+
 def get_principal_role_manager():
     """Get a role manager for principals.
@@ -74,6 +76,7 @@
     return principalRoleManager
 
-class KofaSessionCredentialsPlugin(grok.GlobalUtility,
-                                    SessionCredentialsPlugin):
+
+class KofaSessionCredentialsPlugin(
+        grok.GlobalUtility, SessionCredentialsPlugin):
     """Session plugin that picks usernames/passwords from fields in webforms.
     """
@@ -143,4 +146,5 @@
                 getattr(self, name) == getattr(obj, name, default))
         return False not in result
+
 
 class KofaPrincipal(Principal):
@@ -168,4 +172,5 @@
     def __repr__(self):
         return 'KofaPrincipal(%r)' % self.id
+
 
 class AuthenticatedKofaPrincipalFactory(grok.MultiAdapter):
@@ -200,4 +205,5 @@
         return principal
 
+
 class FailedLoginInfo(grok.Model):
     grok.implements(IFailedLoginInfo)
@@ -224,4 +230,5 @@
         pass
 
+
 class Account(grok.Model):
     """Kofa user accounts store infos about a user.
@@ -237,5 +244,5 @@
 
     def __init__(self, name, password, title=None, description=None,
-                 email=None, phone=None, public_name=None, roles = []):
+                 email=None, phone=None, public_name=None, roles=[]):
         self.name = name
         if title is None:
@@ -270,5 +277,5 @@
             # unset/empty passwords do never match
             return False
-        if self.suspended == True:
+        if self.suspended:
             return False
         passwordmanager = getUtility(IPasswordManager, 'SSHA')
@@ -312,4 +319,5 @@
         self._p_changed = True
         return
+
 
 class UserAuthenticatorPlugin(grok.GlobalUtility):
@@ -387,15 +395,17 @@
         return site['users']
 
+
 class PasswordValidator(grok.GlobalUtility):
 
-  grok.implements(IPasswordValidator)
-
-  def validate_password(self, pw, pw_repeat):
-       errors = []
-       if len(pw) < 3:
-         errors.append('Password must have at least 3 chars.')
-       if pw != pw_repeat:
-         errors.append('Passwords do not match.')
-       return errors
+    grok.implements(IPasswordValidator)
+
+    def validate_password(self, pw, pw_repeat):
+        errors = []
+        if len(pw) < 3:
+            errors.append('Password must have at least 3 chars.')
+        if pw != pw_repeat:
+            errors.append('Passwords do not match.')
+        return errors
+
 
 class LocalRoleSetEvent(object):
@@ -408,4 +418,5 @@
         self.principal_id = principal_id
         self.granted = granted
+
 
 @grok.subscribe(IUserAccount, grok.IObjectRemovedEvent)
@@ -430,4 +441,5 @@
         role_manager.unsetRoleForPrincipal(role_id, principal)
     return
+
 
 @grok.subscribe(IUserAccount, grok.IObjectAddedEvent)
@@ -451,4 +463,5 @@
     return
 
+
 @grok.subscribe(Interface, ILocalRoleSetEvent)
 def handle_local_role_changed(obj, event):
@@ -464,4 +477,5 @@
     user.notifyLocalRoleChanged(event.object, event.role_id, event.granted)
     return
+
 
 @grok.subscribe(Interface, grok.IObjectRemovedEvent)
@@ -474,6 +488,7 @@
     for local_role, user_name, setting in role_map.getPrincipalsAndRoles():
         notify(LocalRoleSetEvent(
-                obj, local_role, user_name, granted=False))
+            obj, local_role, user_name, granted=False))
     return
+
 
 class UserAccountFactory(grok.GlobalUtility):
@@ -493,7 +508,8 @@
         return implementedBy(Account)
 
+
 class UserProcessor(BatchProcessor):
-    """The User Processor processes user accounts, i.e. `Account` objects in the
-    ``users`` container.
+    """The User Processor processes user accounts, i.e. `Account` objects in
+    the ``users`` container.
 
     The `roles` columns must contain Python list
@@ -512,5 +528,5 @@
     iface = IUserAccount
 
-    location_fields = ['name',]
+    location_fields = ['name', ]
     factory_name = 'waeup.UserAccount'
 
@@ -541,6 +557,6 @@
         if user is not None:
             parent = self.getParent(row, site)
-            grok.getSite().logger.info('%s - %s - User removed'
-                % (self.name, row['name']))
+            grok.getSite().logger.info(
+                '%s - %s - User removed' % (self.name, row['name']))
             del parent[user.name]
         pass
@@ -551,5 +567,5 @@
         changed = []
         for key, value in row.items():
-            if  key == 'roles':
+            if key == 'roles':
                 # We cannot simply set the roles attribute here because
                 # we can't assure that the name attribute is set before
@@ -571,6 +587,7 @@
         # Log actions...
         items_changed = ', '.join(changed)
-        grok.getSite().logger.info('%s - %s - %s - updated: %s'
-            % (self.name, filename, row['name'], items_changed))
+        grok.getSite().logger.info(
+            '%s - %s - %s - updated: %s' % (
+                self.name, filename, row['name'], items_changed))
         return
 
@@ -587,6 +604,7 @@
             for role in evalvalue:
                 if role not in all_roles:
-                    errs.append(('roles','invalid role'))
+                    errs.append(('roles', 'invalid role'))
         return errs, inv_errs, conv_dict
+
 
 class UsersPlugin(grok.GlobalUtility):
@@ -607,9 +625,9 @@
             # Add new attributes
             for i in items:
-                if not hasattr(user,i[0]):
-                    setattr(user,i[0],i[1].missing_value)
+                if not hasattr(user, i[0]):
+                    setattr(user, i[0], i[1].missing_value)
                     logger.info(
                         'UsersPlugin: %s attribute %s added.' % (
-                        user.name,i[0]))
+                            user.name, i[0]))
             if not hasattr(user, 'failed_logins'):
                 # add attribute `failed_logins`...
@@ -620,8 +638,8 @@
             for i in self.deprecated_attributes:
                 try:
-                    delattr(user,i)
+                    delattr(user, i)
                     logger.info(
                         'UsersPlugin: %s attribute %s deleted.' % (
-                        user.name,i))
+                            user.name, i))
                 except AttributeError:
                     pass
