Commits

Anonymous committed 7afaec1

[svn r58] clean code & typos.

  • Participants
  • Parent commits d0e9850

Comments (0)

Files changed (8)

File django_authopenid/__init__.py

+# -*- coding: utf-8 -*-
+# Copyright (c) 2007, 2008, Benoît Chesneau
+# 
+# All rights reserved.
+# 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# 
+#      * Redistributions of source code must retain the above copyright
+#      * notice, this list of conditions and the following disclaimer.
+#      * Redistributions in binary form must reproduce the above copyright
+#      * notice, this list of conditions and the following disclaimer in the
+#      * documentation and/or other materials provided with the
+#      * distribution.  Neither the name of the <ORGANIZATION> nor the names
+#      * of its contributors may be used to endorse or promote products
+#      * derived from this software without specific prior written
+#      * permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""
+Django authentification application to *with openid using django auth contrib/.
+
+This application allow a user to connect to you website with :
+ * legacy account : username/password
+ * openid url
+"""
+
+__version__ = "0.9.4"

File django_authopenid/forms.py

 # -*- coding: utf-8 -*-
-"""
- Copyright (c) 2007, 2008, Benoît Chesneau
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-     * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-"""
+# Copyright (c) 2007, 2008, Benoît Chesneau
+# 
+# All rights reserved.
+# 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# 
+#      * Redistributions of source code must retain the above copyright
+#      * notice, this list of conditions and the following disclaimer.
+#      * Redistributions in binary form must reproduce the above copyright
+#      * notice, this list of conditions and the following disclaimer in the
+#      * documentation and/or other materials provided with the
+#      * distribution.  Neither the name of the <ORGANIZATION> nor the names
+#      * of its contributors may be used to endorse or promote products
+#      * derived from this software without specific prior written
+#      * permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 from django import newforms as forms
 # needed for some linux distributions like debian
 try:
     from openid.yadis import xri
-except:
+except ImportError:
     from yadis import xri
 
+__all__ = ['OpenidSigninForm', 'OpenidAuthForm', 'OpenidVerifyForm',
+        'OpenidRegisterForm', 'RegistrationForm', 'ChangepwForm',
+        'ChangeemailForm', 'EmailPasswordForm', 'DeleteForm',
+        'ChangeOpenidForm', 'ChangeEmailForm', 'ChangepwForm']
 
 class OpenidSigninForm(forms.Form):
-    openid_url = forms.CharField(max_length=255, widget=forms.widgets.TextInput(attrs={'class': 'required openid'}))
-    next = forms.CharField(max_length=255,widget=forms.HiddenInput(), required=False)
+    """ signin form """
+    openid_url = forms.CharField(max_length=255, 
+            widget=forms.widgets.TextInput(attrs={'class': 'required openid'}))
+    next = forms.CharField(max_length=255, widget=forms.HiddenInput(), 
+            required=False)
 
     def clean_openid_url(self):
+        """ test if openid is accepted """
         if 'openid_url' in self.cleaned_data:
             openid_url = self.cleaned_data['openid_url']
             if xri.identifierScheme(openid_url) == 'XRI' and getattr(
             return self.cleaned_data['openid_url']
 
     def clean_next(self):
+        """ validate next """
         if 'next' in self.cleaned_data and self.cleaned_data['next'] != "":
             next_url_re = re.compile('^/[-\w/]*$')
             if not next_url_re.match(self.cleaned_data['next']):
-                raise forms.ValidationError(_('next url "%s" is invalid' % self.cleaned_data['next']))
+                raise forms.ValidationError(_('next url "%s" is invalid' % 
+                    self.cleaned_data['next']))
             return self.cleaned_data['next']
 
 
 
 class OpenidAuthForm(forms.Form):
     """ legacy account signin form """
-    next = forms.CharField(max_length=255,widget=forms.HiddenInput(), required=False)
-    username = forms.CharField(max_length=30,  widget=forms.widgets.TextInput(attrs=attrs_dict))
-    password = forms.CharField(max_length=128, widget=forms.widgets.PasswordInput(attrs=attrs_dict))
+    next = forms.CharField(max_length=255, widget=forms.HiddenInput(), 
+            required=False)
+    username = forms.CharField(max_length=30,  
+            widget=forms.widgets.TextInput(attrs=attrs_dict))
+    password = forms.CharField(max_length=128, 
+            widget=forms.widgets.PasswordInput(attrs=attrs_dict))
        
-    def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None):
-        super(OpenidAuthForm, self).__init__(data, files, auto_id, prefix, initial)
-        self.user_cache=None
+    def __init__(self, data=None, files=None, auto_id='id_%s',
+            prefix=None, initial=None): 
+        super(OpenidAuthForm, self).__init__(data, files, auto_id,
+                prefix, initial)
+        self.user_cache = None
             
     def clean_username(self):
-        if 'username' in self.cleaned_data and 'openid_url' not in self.cleaned_data:
+        """ validate username and test if it exists."""
+        if 'username' in self.cleaned_data and \
+                'openid_url' not in self.cleaned_data:
             if not username_re.search(self.cleaned_data['username']):
-                raise forms.ValidationError(_("Usernames can only contain letters, numbers and underscores"))
+                raise forms.ValidationError(_("Usernames can only contain \
+                    letters, numbers and underscores"))
             try:
-                user = User.objects.get(username__exact=self.cleaned_data['username'])
+                user = User.objects.get(
+                        username__exact = self.cleaned_data['username']
+                )
             except User.DoesNotExist:
-                raise forms.ValidationError(_("This username don't exist in database. Please choose another."))
+                raise forms.ValidationError(_("This username don't exist \
+                    in database. Please choose another."))
             return self.cleaned_data['username']
 
     def clean_password(self):
-        if 'username' in self.cleaned_data and 'password' in self.cleaned_data:
-            self.user_cache =  authenticate(username=self.cleaned_data['username'], password=self.cleaned_data['password'])
+        """" test if password is valid for this username """
+        if 'username' in self.cleaned_data and \
+                'password' in self.cleaned_data:
+            self.user_cache =  authenticate(
+                    username=self.cleaned_data['username'], 
+                    password=self.cleaned_data['password']
+            )
             if self.user_cache is None:
-                raise forms.ValidationError(_("Please enter a correct username and password. Note that both fields are case-sensitive."))
+                raise forms.ValidationError(_("Please enter a correct \
+                    username and password. Note that both fields are \
+                    case-sensitive."))
             elif self.user_cache.is_active == False:
                 raise forms.ValidationError(_("This account is inactive."))
             return self.cleaned_data['password']
 
     def clean_next(self):
-        if 'next' in self.cleaned_data and self.cleaned_data['next'] != "":
+        """ validate next url """
+        if 'next' in self.cleaned_data and \
+                self.cleaned_data['next'] != "":
             next_url_re = re.compile('^/[-\w/]*$')
             if not next_url_re.match(self.cleaned_data['next']):
-                raise forms.ValidationError(_('next url "%s" is invalid' % self.cleaned_data['next']))
+                raise forms.ValidationError(
+                        _('next url "%s" is invalid' % 
+                            self.cleaned_data['next'])
+                )
             return self.cleaned_data['next']
             
     def get_user(self):
+        """ get authenticated user """
         return self.user_cache
             
 
 class OpenidRegisterForm(forms.Form):
     """ openid signin form """
-    next = forms.CharField(max_length=255,widget=forms.HiddenInput(), required=False)
-
-    username = forms.CharField(max_length=30, widget=forms.widgets.TextInput(attrs=attrs_dict))
+    next = forms.CharField(max_length=255, widget=forms.HiddenInput(), 
+            required=False)
+    username = forms.CharField(max_length=30, 
+            widget=forms.widgets.TextInput(attrs=attrs_dict))
     email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict, 
         maxlength=200)), label=u'Email address')
     
     def clean_username(self):
+        """ test if username is valid and exist in database """
         if 'username' in self.cleaned_data:
             if not username_re.search(self.cleaned_data['username']):
-                raise forms.ValidationError(_("Usernames can only contain letters, numbers and underscores"))
+                raise forms.ValidationError(_("Usernames can only contain \
+                    letters, numbers and underscores"))
             try:
-                user = User.objects.get(username__exact=self.cleaned_data['username'])
+                user = User.objects.get(
+                        username__exact = self.cleaned_data['username']
+                        )
             except User.DoesNotExist:
                 return self.cleaned_data['username']
-            raise forms.ValidationError(_("This username is already taken. Please choose another."))
+            raise forms.ValidationError(_("This username is already \
+                taken. Please choose another."))
             
     def clean_email(self):
         """For security reason one unique email in database"""
         if 'email' in self.cleaned_data:
             try:
-                user = User.objects.get(email=self.cleaned_data['email'])
+                user = User.objects.get(email = self.cleaned_data['email'])
             except User.DoesNotExist:
                 return self.cleaned_data['email']
-            raise forms.ValidationError(_("This email is already registered in our database. Please choose another."))
+            raise forms.ValidationError(_("This email is already \
+                registered in our database. Please choose another."))
  
     
 class OpenidVerifyForm(forms.Form):
     """ openid verify form (associate an openid with an account) """
-    next = forms.CharField(max_length=255,widget=forms.HiddenInput(), required=False)
-    username = forms.CharField(max_length=30, widget=forms.widgets.TextInput(attrs=attrs_dict))
-    password = forms.CharField(max_length=128, widget=forms.widgets.PasswordInput(attrs=attrs_dict))
-     
+    next = forms.CharField(max_length=255, widget = forms.HiddenInput(), 
+            required=False)
+    username = forms.CharField(max_length=30, 
+            widget=forms.widgets.TextInput(attrs=attrs_dict))
+    password = forms.CharField(max_length=128, 
+            widget=forms.widgets.PasswordInput(attrs=attrs_dict))
+    
+    def __init__(self, data=None, files=None, auto_id='id_%s',
+            prefix=None, initial=None): 
+        super(OpenidVerifyForm, self).__init__(data, files, auto_id,
+                prefix, initial)
+        self.user_cache = None
+
     def clean_username(self):
+        """ validate username """
         if 'username' in self.cleaned_data:
             if not username_re.search(self.cleaned_data['username']):
-                raise forms.ValidationError(_("Usernames can only contain letters, numbers and underscores"))
+                raise forms.ValidationError(_("Usernames can only contain \
+                    letters, numbers and underscores"))
             try:
-                user = User.objects.get(username__exact=self.cleaned_data['username'])
+                user = User.objects.get(
+                        username__exact = self.cleaned_data['username']
+                )
             except User.DoesNotExist:
-                raise forms.ValidationError(_("This username don't exist. Please choose another."))
+                raise forms.ValidationError(_("This username don't exist. \
+                        Please choose another."))
             return self.cleaned_data['username']
             
     def clean_password(self):
-        if 'username' in self.cleaned_data and 'password' in self.cleaned_data:
-            self.user_cache =  authenticate(username=self.cleaned_data['username'], password=self.cleaned_data['password'])
+        """ test if password is valid for this user """
+        if 'username' in self.cleaned_data and \
+                'password' in self.cleaned_data:
+            self.user_cache =  authenticate(
+                    username = self.cleaned_data['username'], 
+                    password = self.cleaned_data['password']
+            )
             if self.user_cache is None:
-                raise forms.ValidationError(_("Please enter a correct username and password. Note that both fields are case-sensitive."))
+                raise forms.ValidationError(_("Please enter a correct \
+                    username and password. Note that both fields are \
+                    case-sensitive."))
             elif self.user_cache.is_active == False:
                 raise forms.ValidationError(_("This account is inactive."))
             return self.cleaned_data['password']
             
     def get_user(self):
+        """ get authenticated user """
         return self.user_cache
 
 
 class RegistrationForm(forms.Form):
     """ legacy registration form """
 
-    next = forms.CharField(max_length=255,widget=forms.HiddenInput(), required=False)
+    next = forms.CharField(max_length=255, widget=forms.HiddenInput(), 
+            required=False)
     username = forms.CharField(max_length=30,
-                               widget=forms.TextInput(attrs=attrs_dict),
-                               label=u'Username')
+            widget=forms.TextInput(attrs=attrs_dict),
+            label=u'Username')
     email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict,
-        maxlength=200)), label=u'Email address')
+            maxlength=200)), label=u'Email address')
     password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict),
-                                label=u'Password')
+            label=u'Password')
     password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict),
-                                label=u'Password (again, to catch typos)')
+            label=u'Password (again, to catch typos)')
 
     def clean_username(self):
         """
         """
         if 'username' in self.cleaned_data:
             if not username_re.search(self.cleaned_data['username']):
-                raise forms.ValidationError(u'Usernames can only contain letters, numbers and underscores')
+                raise forms.ValidationError(u'Usernames can only contain \
+                        letters, numbers and underscores')
             try:
-                user = User.objects.get(username__exact=self.cleaned_data['username'])
+                user = User.objects.get(
+                        username__exact = self.cleaned_data['username']
+                )
+
             except User.DoesNotExist:
                 return self.cleaned_data['username']
-            raise forms.ValidationError(u'This username is already taken. Please choose another.')
+            raise forms.ValidationError(u'This username is already taken. \
+                    Please choose another.')
 
     def clean_email(self):
+        """ validate if email exist in database
+        :return: raise error if it exist """
         if 'email' in self.cleaned_data:
             try:
-                user = User.objects.get(email=self.cleaned_data['email'])
-            except:
+                user = User.objects.get(email = self.cleaned_data['email'])
+            except User.DoesNotExist:
                 return self.cleaned_data['email']
-            raise forms.ValidationError(u'This email is already registered in our database. Please choose another.')
+            raise forms.ValidationError(u'This email is already registered \
+                    in our database. Please choose another.')
         return self.cleaned_data['email']
     
     def clean_password2(self):
         Validates that the two password inputs match.
         
         """
-        if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data and \
-           self.cleaned_data['password1'] == self.cleaned_data['password2']:
+        if 'password1' in self.cleaned_data and \
+                'password2' in self.cleaned_data and \
+                self.cleaned_data['password1'] == \
+                self.cleaned_data['password2']:
             return self.cleaned_data['password2']
-        raise forms.ValidationError(u'You must type the same password each time')
+        raise forms.ValidationError(u'You must type the same password each \
+                time')
 
 
 class ChangepwForm(forms.Form):
         self.user = user
 
     def clean_oldpw(self):
+        """ test old password """
         if not self.user.check_password(self.cleaned_data['oldpw']):
-            raise forms.ValidationError(_("Old password is wrong. Please enter a valid password."))
+            raise forms.ValidationError(_("Old password is wrong. \
+                    Please enter a valid password."))
         return self.cleaned_data['oldpw']
     
     def clean_password2(self):
         """
         Validates that the two password inputs match.
-        
         """
-        if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data and \
+        if 'password1' in self.cleaned_data and \
+                'password2' in self.cleaned_data and \
            self.cleaned_data['password1'] == self.cleaned_data['password2']:
             return self.cleaned_data['password2']
         raise forms.ValidationError(_("new passwords do not match each other"))
         maxlength=200)), label=u'Email address')
     password = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict))
 
-    def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, 
+    def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, \
             initial=None, user=None):
         if user is None:
             raise TypeError("Keyword argument 'user' must be supplied")
-        super(ChangeemailForm, self).__init__(data, files, auto_id, prefix, initial)
-        self.test_openid=False
+        super(ChangeemailForm, self).__init__(data, files, auto_id, 
+                prefix, initial)
+        self.test_openid = False
         self.user = user
 
     def clean_password(self):
+        """ check if we have to test a legacy account or not """
         if 'password' in self.cleaned_data:
             if not self.user.check_password(self.cleaned_data['password']):
-                self.test_openid=True
+                self.test_openid = True
         return self.cleaned_data['password']
                 
 class ChangeopenidForm(forms.Form):
     """ change openid form """
-    openid_url = forms.CharField(max_length=255,widget=forms.TextInput(attrs={'class': "required" }))
+    openid_url = forms.CharField(max_length=255,
+            widget=forms.TextInput(attrs={'class': "required" }))
+
     def __init__(self, data=None, user=None, *args, **kwargs):
         if user is None:
             raise TypeError("Keyword argument 'user' must be supplied")
     confirm = forms.CharField(widget=forms.CheckboxInput(attrs=attrs_dict))
     password = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict))
 
-    def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, 
-            initial=None, user=None):
+    def __init__(self, data=None, files=None, auto_id='id_%s',
+            prefix=None, initial=None, user=None):
         super(DeleteForm, self).__init__(data, files, auto_id, prefix, initial)
-        self.test_openid=False
+        self.test_openid = False
         self.user = user
 
     def clean_password(self):
+        """ check if we have to test a legacy account or not """
         if 'password' in self.cleaned_data:
             if not self.user.check_password(self.cleaned_data['password']):
-                self.test_openid=True
+                self.test_openid = True
         return self.cleaned_data['password']
 
 
 class EmailPasswordForm(forms.Form):
     """ send new password form """
-    username = forms.CharField(max_length=30,widget=forms.TextInput(attrs={'class': "required" }))
+    username = forms.CharField(max_length=30,
+            widget=forms.TextInput(attrs={'class': "required" }))
 
-    def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None):
-        super(EmailPasswordForm, self).__init__(data, files, auto_id, prefix, initial)
-        self.user_cache=None
+    def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, 
+            initial=None):
+        super(EmailPasswordForm, self).__init__(data, files, auto_id, 
+                prefix, initial)
+        self.user_cache = None
 
 
     def clean_username(self):
+        """ get user for this username """
         if 'username' in self.cleaned_data:
             try:
-                self.user_cache=User.objects.get(username=self.cleaned_data['username'])
+                self.user_cache = User.objects.get(
+                        username = self.cleaned_data['username'])
             except:
                 raise forms.ValidationError(_("Incorrect username."))
         return self.cleaned_data['username']

File django_authopenid/middleware.py

 # -*- coding: utf-8 -*-
+
+__all__ = ["OpenIDMiddleware"]
+
 class OpenIDMiddleware(object):
     """
     Populate request.openid. This comes either from cookie or from

File django_authopenid/models.py

 
 import md5, random, sys, os, time
 
+__all__ = ['Nonce', 'Association', 'UserAssociation', 
+        'UserPasswordQueueManager', 'UserPasswordQueue']
+
 class Nonce(models.Model):
+    """ openid nonce """
     server_url = models.CharField(max_length=255)
     timestamp = models.IntegerField()
     salt = models.CharField(max_length=40)
 
     
 class Association(models.Model):
+    """ association openid url and lifetime """
     server_url = models.TextField(max_length=2047)
     handle = models.CharField(max_length=255)
     secret = models.TextField(max_length=255) # Stored base64 encoded
     model to manage association between openid and user 
     """
     openid_url = models.CharField(blank=False, max_length=255)
-    user = models.ForeignKey(User,unique=True)
+    user = models.ForeignKey(User, unique=True)
     
     def __unicode__(self):
         return "Openid %s with user %s" % (self.openid_url, self.user)
         
     class Admin:
-        pass
+        """ default admin class """
 
 
 class UserPasswordQueueManager(models.Manager):
+    """ manager for UserPasswordQueue object """
     def get_new_confirm_key(self):
         "Returns key that isn't being used."
         # The random module is seeded when this Apache child is created.
         # Use SECRET_KEY as added salt.
         while 1:
-            confirm_key = md5.new("%s%s%s%s" % (random.randint(0, sys.maxint - 1), os.getpid(), time.time(), settings.SECRET_KEY)).hexdigest()
+            confirm_key = md5.new("%s%s%s%s" % (
+                random.randint(0, sys.maxint - 1), os.getpid(),
+                time.time(), settings.SECRET_KEY)).hexdigest()
             try:
                 self.get(confirm_key=confirm_key)
             except self.model.DoesNotExist:
 
     objects = UserPasswordQueueManager()
 
-
     def __unicode__(self):
         return self.user.username

File django_authopenid/urls.py

      # manage account registration
     url(r'^%s$' % _('signin/'), 'signin', name='user_signin'),
     url(r'^%s$' % _('signout/'), 'signout', name='user_signout'),
-    url(r'^%s%s$' % (_('signin/'), _('complete/')), 'complete_signin', name='user_complete_signin'),
+    url(r'^%s%s$' % (_('signin/'), _('complete/')), 'complete_signin', 
+        name='user_complete_signin'),
     url(r'^%s$' % _('register/'), 'register', name='user_register'),
     url(r'^%s$' % _('signup/'), 'signup', name='user_signup'),
     url(r'^%s$' % _('sendpw/'), 'sendpw', name='user_sendpw'),
-    url(r'^%s%s$' % (_('password/'), _('confirm/')), 'confirmchangepw', name='user_confirmchangepw'),
+    url(r'^%s%s$' % (_('password/'), _('confirm/')), 'confirmchangepw', 
+        name='user_confirmchangepw'),
 
     # manage account settings
     url(r'^$', 'account_settings', name='user_account_settings'),
     url(r'^%s$' % _('email/'), 'changeemail', name='user_changeemail'),
     url(r'^%s$' % _('openid/'), 'changeopenid', name='user_changeopenid'),
     url(r'^%s$' % _('delete/'), 'delete', name='user_delete'),
-    
-    
 )

File django_authopenid/util.py

 # -*- coding: utf-8 -*-
 from openid.store.interface import OpenIDStore
 from openid.association import Association as OIDAssociation
-from openid.association import Association
 from openid.extensions import sreg
 import openid.store
 
 
 from models import Association, Nonce
 
+__all__ = ['OpenID', 'DjangoOpenIDStore', 'from_openid_response']
+
 class OpenID:
-    def __init__(self, openid, issued, attrs=None, sreg=None):
-        self.openid = openid
+    def __init__(self, openid_, issued, attrs=None, sreg_=None):
+        self.openid = openid_
         self.issued = issued
         self.attrs = attrs or {}
-        self.sreg = sreg or {}
+        self.sreg = sreg_ or {}
         self.is_iname = (xri.identifierScheme(openid) == 'XRI')
     
     def __repr__(self):
         if abs(timestamp - time.time()) > openid.store.nonce.SKEW:
             return False
         
-        query =[
+        query = [
                 Q(server_url__exact=server_url),
                 Q(timestamp__exact=timestamp),
                 Q(salt__exact=salt),
                     server_url=server_url,
                     timestamp=timestamp,
                     salt=salt
-            );
+            )
             ononce.save()
             return True
         
         return False
 
 def from_openid_response(openid_response):
+    """ return openid object from response """
     issued = int(time.time())
     return OpenID(
         openid_response.identity_url, issued, openid_response.signed_fields, 

File django_authopenid/views.py

 # -*- coding: utf-8 -*-
-"""
- Copyright (c) 2007, 2008, Benoît Chesneau
- Copyright (c) 2007, Simon Willison, original work on django-openid
+# Copyright (c) 2007, 2008, Benoît Chesneau
+# 
+# All rights reserved.
+# 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# 
+#      * Redistributions of source code must retain the above copyright
+#      * notice, this list of conditions and the following disclaimer.
+#      * Redistributions in binary form must reproduce the above copyright
+#      * notice, this list of conditions and the following disclaimer in the
+#      * documentation and/or other materials provided with the
+#      * distribution.  Neither the name of the <ORGANIZATION> nor the names
+#      * of its contributors may be used to endorse or promote products
+#      * derived from this software without specific prior written
+#      * permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-     * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-"""
-
-
-from django.http import HttpResponse, HttpResponseRedirect, get_host
-from django.shortcuts import get_object_or_404, render_to_response as render
+from django.http import HttpResponseRedirect, get_host
+from django.shortcuts import render_to_response as render
 from django.template import RequestContext, loader, Context
 from django.conf import settings
 from django.contrib.auth.models import User
-from django.contrib.auth import authenticate,login,logout
+from django.contrib.auth import login, logout
 from django.contrib.auth.decorators import login_required
 from django.core.urlresolvers import reverse
 from django.utils.html import escape
 from django.utils.translation import ugettext as _
 from django.contrib.sites.models import Site
-from django.utils.encoding import smart_str
-from django.utils.http import urlquote_plus, urlquote
+from django.utils.http import urlquote_plus
 from django.core.mail import send_mail
 
 from openid.consumer.consumer import Consumer, \
 # needed for some linux distributions like debian
 try:
     from openid.yadis import xri
-except:
+except ImportError:
     from yadis import xri
 
-import md5, re, time, urllib
+import re
+import urllib
 
 
 from util import OpenID, DjangoOpenIDStore, from_openid_response
 def is_valid_next_url(next):
     # When we allow this:
     #   /openid/?next=/welcome/
-    # For security reasons we want to restrict the next= bit to being a local 
-    # path, not a complete URL.
+    # For security reasons we want to restrict the next= bit 
+    # to being a local path, not a complete URL.
     return bool(next_url_re.match(next))
 
-def ask_openid(request, openid_url, redirect_to, on_failure=None, sreg_request=None):
+def ask_openid(request, openid_url, redirect_to, on_failure=None,
+        sreg_request=None):
     """ basic function to ask openid and return response """
 
     on_failure = on_failure or signin_failure
             settings, 'OPENID_DISALLOW_INAMES', False
     ):
         msg = _("i-names are not supported")
-        return on_failure(request,msg)
+        return on_failure(request, msg)
     consumer = Consumer(request.session, DjangoOpenIDStore())
     try:
         auth_request = consumer.begin(openid_url)
-    except:
-        msg =_("The OpenID %s was invalid" % openid_url)
-        return on_failure(request,msg)
+    except DiscoveryFailure:
+        msg = _("The OpenID %s was invalid" % openid_url)
+        return on_failure(request, msg)
 
     if sreg_request:
         auth_request.addExtension(sreg_request)
     return HttpResponseRedirect(redirect_url)
 
 def complete(request, on_success=None, on_failure=None, return_to=None):
+    """ complete openid signin """
     on_success = on_success or default_on_success
     on_failure = on_failure or default_on_failure
     
     consumer = Consumer(request.session, DjangoOpenIDStore())
-    openid_response = consumer.complete(dict(request.GET.items()), return_to)
+    openid_response = consumer.complete(dict(request.GET.items()),
+            return_to)
     
     if openid_response.status == SUCCESS:
-        return on_success(request, openid_response.identity_url, openid_response)
+        return on_success(request, openid_response.identity_url,
+                openid_response)
     elif openid_response.status == CANCEL:
         return on_failure(request, 'The request was cancelled')
     elif openid_response.status == FAILURE:
         assert False, "Bad openid status: %s" % openid_response.status
 
 def default_on_success(request, identity_url, openid_response):
-    request.session['openid']=from_openid_response(openid_response)
+    """ default action on openid signin success """
+    request.session['openid'] = from_openid_response(openid_response)
     
     next = request.GET.get('next', '').strip()
     if not next or not is_valid_next_url(next):
     return HttpResponseRedirect(next)
 
 def default_on_failure(request, message):
+    """ default failure action on signin """
     return render('openid_failure.html', {
         'message': message
     })
                 if not next:
                     next = getattr(settings, 'OPENID_REDIRECT_NEXT', '/')
 
-                sreg_req = sreg.SRegRequest(optional=['nickname','email'])
-                redirect_to = "%s?%s" % (
-                        get_url_host(request) + reverse('user_complete_signin'), 
-                        urllib.urlencode({'next':next}))
+                sreg_req = sreg.SRegRequest(optional=['nickname', 'email'])
+                redirect_to = "%s%s?%s" % (
+                        get_url_host(request),
+                        reverse('user_complete_signin'), 
+                        urllib.urlencode({'next':next})
+                )
 
                 return ask_openid(request, 
                         form_signin.cleaned_data['openid_url'], 
             # perform normal django authentification
             form_auth = OpenidAuthForm(request.POST)
             if form_auth.is_valid():
-                u = form_auth.get_user()
-                login(request, u)
+                user_ = form_auth.get_user()
+                login(request, user_)
 
                 next = form_auth.cleaned_data['next']
                 if not next:
 
 def complete_signin(request):
     """ in case of complete signin with openid """
-    return complete(request, signin_success, signin_failure, get_url_host(request) + reverse('user_complete_signin'))
+    return complete(request, signin_success, signin_failure,
+            get_url_host(request) + reverse('user_complete_signin'))
 
 
 def signin_success(request, identity_url, openid_response):
     if openid isn't registered user is redirected to register page.
     """
 
-    openid=from_openid_response(openid_response)
-    request.session['openid']=openid
+    openid_ = from_openid_response(openid_response)
+    request.session['openid'] = openid_
 
     try:
-        rel = UserAssociation.objects.get(openid_url__exact=str(openid))
+        rel = UserAssociation.objects.get(openid_url__exact = str(openid_))
     except:
         # try to register this new user
         return register(request)
-    u = rel.user
-    if u.is_active:
-        u.backend = "django.contrib.auth.backends.ModelBackend"
-        login(request,u)
+    user_ = rel.user
+    if user_.is_active:
+        user_.backend = "django.contrib.auth.backends.ModelBackend"
+        login(request, user_)
 
     next = request.GET.get('next', '').strip()
     if not next or not is_valid_next_url(next):
 
 def is_association_exist(openid_url):
     """ test if an openid is already in database """
-    is_exist=True
+    is_exist = True
     try:
-        o=UserAssociation.objects.get(openid_url__exact=openid_url)
+        uassoc = UserAssociation.objects.get(openid_url__exact = openid_url)
     except:
-        is_exist=False
+        is_exist = False
     return is_exist
 
 def register(request):
         next = getattr(settings, 'OPENID_REDIRECT_NEXT', '/')
 
 
-    openid = request.session.get('openid', None)
-    if not openid:
-         return HttpResponseRedirect(reverse('user_signin') + next)
+    openid_ = request.session.get('openid', None)
+    if not openid_:
+        return HttpResponseRedirect(reverse('user_signin') + next)
 
-    nickname = openid.sreg.get('nickname', '')
-    email = openid.sreg.get('email', '')
+    nickname = openid_.sreg.get('nickname', '')
+    email = openid_.sreg.get('email', '')
     
     form1 = OpenidRegisterForm(initial={
         'next': next,
     })
     
     if request.POST:
-        just_completed=False
+        just_completed = False
         if 'bnewaccount' in request.POST.keys():
             form1 = OpenidRegisterForm(request.POST)
             if form1.is_valid():
                     next = getattr(settings, 'OPENID_REDIRECT_NEXT', '/')
                 is_redirect = True
                 tmp_pwd = User.objects.make_random_password()
-                u = User.objects.create_user(form1.cleaned_data['username'],form1.cleaned_data['email'], tmp_pwd)
+                user_ = User.objects.create_user(form1.cleaned_data['username'],
+                         form1.cleaned_data['email'], tmp_pwd)
                 
                 # make association with openid
-                ua = UserAssociation(openid_url=str(openid),user_id=u.id)
-                ua.save()
+                uassoc = UserAssociation(openid_url=str(openid_),
+                        user_id=user_.id)
+                uassoc.save()
                     
                 # login 
-                u.backend = "django.contrib.auth.backends.ModelBackend"
-                login(request, u)
+                user_.backend = "django.contrib.auth.backends.ModelBackend"
+                login(request, user_)
         elif 'bverify' in request.POST.keys():
             form2 = OpenidVerifyForm(request.POST)
             if form2.is_valid():
                 next = form2.cleaned_data['next']
                 if not next:
                     next = getattr(settings, 'OPENID_REDIRECT_NEXT', '/')
-                u = form2.get_user()
+                user_ = form2.get_user()
 
-                ua = UserAssociation(openid_url=str(openid),user_id=u.id)
-                ua.save()
-                login(request, u)
+                uassoc = UserAssociation(openid_url=str(openid_),
+                        user_id=user_.id)
+                uassoc.save()
+                login(request, user_)
         
         # redirect, can redirect only if forms are valid.
         if is_redirect:
     """
     next = request.REQUEST.get('next', '')
 
-    form_signin = OpenidSigninForm(initial={'next':next})
-    form_auth = OpenidAuthForm(initial={'next':next})
+    form_signin = OpenidSigninForm(initial={'next': next})
+    form_auth = OpenidAuthForm(initial={'next': next})
 
     return render('authopenid/signin.html', {
         'msg': message,
             if not next or not is_valid_next_url(next):
                 next = getattr(settings, 'OPENID_REDIRECT_NEXT', '/')
 
-            user = User.objects.create_user(form.cleaned_data['username'],form.cleaned_data['email'], form.cleaned_data['password1'])
+            user_ = User.objects.create_user( form.cleaned_data['username'],
+                    form.cleaned_data['email'], form.cleaned_data['password1'])
            
-            user.backend = "django.contrib.auth.backends.ModelBackend"
-            login(request, user)
+            user_.backend = "django.contrib.auth.backends.ModelBackend"
+            login(request, user_)
             
             # send email
             current_domain = Site.objects.get_current().domain
             subject = _("Welcome")
-            message_template = loader.get_template('authopenid/confirm_email.txt')
-            message_context = Context({ 'site_url': 'http://%s/' % current_domain,
-                                        'username': form.cleaned_data['username'],
-                                        'password': form.cleaned_data['password1'] })
+            message_template = loader.get_template(
+                    'authopenid/confirm_email.txt'
+            )
+            message_context = Context({ 
+                'site_url': 'http://%s/' % current_domain,
+                'username': form.cleaned_data['username'],
+                'password': form.cleaned_data['password1'] 
+            })
             message = message_template.render(message_context)
-            send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [user.email])
+            send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, 
+                    [user_.email])
             
             return HttpResponseRedirect(next)
     
         'form2': form_signin,
         'action': request.path,
         'action_signin': action_signin,
-        },context_instance=RequestContext(request))
+        }, context_instance=RequestContext(request))
 
 def signout(request):
     """
     is_openid = True
 
     try:
-        o=UserAssociation.objects.get(user__username__exact=request.user.username)
+        uassoc = UserAssociation.objects.get(
+                user__username__exact=request.user.username
+        )
     except:
         is_openid = False
 
 
-    return render('authopenid/settings.html',
-            {'msg': msg, 'settings_path': request.path, 'is_openid': is_openid},
-            context_instance=RequestContext(request))
+    return render('authopenid/settings.html', {
+        'msg': msg, 
+        'settings_path': request.path, 
+        'is_openid': is_openid
+        }, context_instance=RequestContext(request))
 account_settings = login_required(account_settings)
 
 def changepw(request):
     template: authopenid/changepw.html
     """
     
-    u = request.user
+    user_ = request.user
     
     if request.POST:
-        form = ChangepwForm(request.POST, user=u)
+        form = ChangepwForm(request.POST, user=user_)
         if form.is_valid():
-            u.set_password(form.cleaned_data['password1'])
-            u.save()
-            msg=_("Password changed.") 
-            redirect="%s?msg=%s" % (reverse('user_account_settings'),urlquote_plus(msg))
+            user_.set_password(form.cleaned_data['password1'])
+            user_.save()
+            msg = _("Password changed.") 
+            redirect = "%s?msg=%s" % (
+                    reverse('user_account_settings'),
+                    urlquote_plus(msg))
             return HttpResponseRedirect(redirect)
     else:
-        form=ChangepwForm(user=u)
+        form = ChangepwForm(user=user_)
 
     return render('authopenid/changepw.html', {'form': form },
                                 context_instance=RequestContext(request))
 
     extension_args = {}
  
-    u = request.user
+    user_ = request.user
     
     redirect_to = get_url_host(request) + reverse('user_changeemail')
 
     if request.POST:
-        form = ChangeemailForm(request.POST, user=u)
+        form = ChangeemailForm(request.POST, user=user_)
         if form.is_valid():
             if not form.test_openid:
-                u.email = form.cleaned_data['email']
-                u.save()
-                msg=_("Email changed.") 
-                redirect="%s?msg=%s" % (reverse('user_account_settings'),urlquote_plus(msg))
+                user_.email = form.cleaned_data['email']
+                user_.save()
+                msg = _("Email changed.") 
+                redirect = "%s?msg=%s" % (reverse('user_account_settings'),
+                        urlquote_plus(msg))
                 return HttpResponseRedirect(redirect)
             else:
                 request.session['new_email'] = form.cleaned_data['email']
-                return ask_openid(request, form.cleaned_data['password'], redirect_to, on_failure=emailopenid_failure)    
+                return ask_openid(request, form.cleaned_data['password'], 
+                        redirect_to, on_failure=emailopenid_failure)    
     elif not request.POST and 'openid.mode' in request.GET:
-        return complete(request, emailopenid_success, emailopenid_failure, redirect_to) 
+        return complete(request, emailopenid_success, 
+                emailopenid_failure, redirect_to) 
     else:
-        form = ChangeemailForm(initial={'email': u.email}, user=u)
+        form = ChangeemailForm(initial={'email': user_.email},
+                user=user_)
     
     return render('authopenid/changeemail.html', 
             {'form': form }, context_instance=RequestContext(request))
 changeemail = login_required(changeemail)
 
 def emailopenid_success(request, identity_url, openid_response):
-    openid=from_openid_response(openid_response)
+    openid_ = from_openid_response(openid_response)
 
-    u = request.user
+    user_ = request.user
     try:
-        o=UserAssociation.objects.get(openid_url__exact=identity_url)
+        uassoc = UserAssociation.objects.get(
+                openid_url__exact=identity_url
+        )
     except:
-        return emailopenid_failure(request, _("No openid % associated in our database" % identity_url))
+        return emailopenid_failure(request, 
+                _("No openid % associated in our database" % identity_url))
 
-    if o.user.username != request.user.username:
-        return emailopenid_failure(request, _("The openid %s isn't associated to current logged user" % identity_url))
+    if uassoc.user.username != request.user.username:
+        return emailopenid_failure(request, 
+                _("The openid %s isn't associated to current logged user" % 
+                    identity_url))
     
-    new_email=request.session.get('new_email', '')
+    new_email = request.session.get('new_email', '')
     if new_email:
-        u.email=new_email
-        u.save()
+        user_.email = new_email
+        user_.save()
         del request.session['new_email']
-    msg=_("Email Changed.")
+    msg = _("Email Changed.")
 
-    redirect="%s?msg=%s" % (reverse('user_account_settings'),urlquote_plus(msg))
+    redirect = "%s?msg=%s" % (reverse('user_account_settings'),
+            urlquote_plus(msg))
     return HttpResponseRedirect(redirect)
     
 
 def emailopenid_failure(request, message):
-    redirect_to="%s?msg=%s" % (reverse('user_changeemail'), urlquote_plus(message))
+    redirect_to = "%s?msg=%s" % (
+            reverse('user_changeemail'), urlquote_plus(message))
     return HttpResponseRedirect(redirect_to)
  
 
 def changeopenid(request):
     """
-    change openid view. Allow user to change openid associated to its username.
+    change openid view. Allow user to change openid 
+    associated to its username.
 
     url : /changeopenid/
 
     """
 
     extension_args = {}
-    openid_url=''
-    has_openid=True
+    openid_url = ''
+    has_openid = True
     msg = request.GET.get('msg', '')
         
-    u = request.user
+    user_ = request.user
 
     try:
-        uopenid=UserAssociation.objects.get(user=u)
+        uopenid = UserAssociation.objects.get(user=user_)
         openid_url = uopenid.openid_url
     except:
-        has_openid=False
+        has_openid = False
     
     redirect_to = get_url_host(request) + reverse('user_changeopenid')
     if request.POST and has_openid:
-        form=ChangeopenidForm(request.POST, user=u)
+        form = ChangeopenidForm(request.POST, user=user_)
         if form.is_valid():
-            return ask_openid(request, form.cleaned_data['openid_url'], redirect_to, on_failure=changeopenid_failure)
+            return ask_openid(request, form.cleaned_data['openid_url'],
+                    redirect_to, on_failure=changeopenid_failure)
     elif not request.POST and has_openid:
         if 'openid.mode' in request.GET:
-            return complete(request, changeopenid_success, changeopenid_failure, redirect_to)    
+            return complete(request, changeopenid_success,
+                    changeopenid_failure, redirect_to)    
 
-    form = ChangeopenidForm(initial={'openid_url': openid_url }, user=u)
-    return render('authopenid/changeopenid.html', {'form': form,
-        'has_openid': has_openid, 'msg': msg }, context_instance=RequestContext(request))
+    form = ChangeopenidForm(initial={'openid_url': openid_url }, user=user_)
+    return render('authopenid/changeopenid.html', {
+        'form': form,
+        'has_openid': has_openid, 
+        'msg': msg 
+        }, context_instance=RequestContext(request))
 changeopenid = login_required(changeopenid)
 
 def changeopenid_success(request, identity_url, openid_response):
-    openid=from_openid_response(openid_response)
-    is_exist=True
+    openid_ = from_openid_response(openid_response)
+    is_exist = True
     try:
-        o=UserAssociation.objects.get(openid_url__exact=identity_url)
+        uassoc = UserAssociation.objects.get(openid_url__exact=identity_url)
     except:
-        is_exist=False
+        is_exist = False
         
     if not is_exist:
         try:
-            o=UserAssociation.objects.get(user__username__exact=request.user.username)
-            o.openid_url=identity_url
-            o.save()
+            uassoc = UserAssociation.objects.get(
+                    user__username__exact=request.user.username
+            )
+            uassoc.openid_url = identity_url
+            uassoc.save()
         except:
-            o=UserAssociation(user=request.user,openid_url=identity_url)
-            o.save()
-    elif o.user.username != request.user.username:
-        return changeopenid_failure(request, _('This openid is already associated with another account.'))
+            uassoc = UserAssociation(user=request.user, 
+                    openid_url=identity_url)
+            uassoc.save()
+    elif uassoc.user.username != request.user.username:
+        return changeopenid_failure(request, 
+                _('This openid is already associated with another account.'))
 
     request.session['openids'] = []
-    request.session['openids'].append(openid)
+    request.session['openids'].append(openid_)
 
-    msg=_("Openid %s associated with your account." % identity_url) 
-    redirect="%s?msg=%s" % (reverse('user_account_settings'), urlquote_plus(msg))
+    msg = _("Openid %s associated with your account." % identity_url) 
+    redirect = "%s?msg=%s" % (
+            reverse('user_account_settings'), 
+            urlquote_plus(msg))
     return HttpResponseRedirect(redirect)
     
 
 def changeopenid_failure(request, message):
-    redirect_to="%s?msg=%s" % (reverse('user_changeopenid'), urlquote_plus(message))
+    redirect_to = "%s?msg=%s" % (
+            reverse('user_changeopenid'), 
+            urlquote_plus(message))
     return HttpResponseRedirect(redirect_to)
   
 
     template : authopenid/delete.html
     """
 
-    extension_args={}
+    extension_args = {}
     
-    u = request.user
+    user_ = request.user
 
     redirect_to = get_url_host(request) + reverse('user_delete') 
     if request.POST:
-        form = DeleteForm(request.POST, user=u)
+        form = DeleteForm(request.POST, user=user_)
         if form.is_valid():
             if not form.test_openid:
-                u.delete() 
+                user_.delete() 
                 return signout(request)
             else:
-                return ask_openid(request, form.cleaned_data['password'], redirect_to, on_failure=deleteopenid_failure)
+                return ask_openid(request, form.cleaned_data['password'],
+                        redirect_to, on_failure=deleteopenid_failure)
     elif not request.POST and 'openid.mode' in request.GET:
-        return complete(request, deleteopenid_success, deleteopenid_failure, redirect_to) 
+        return complete(request, deleteopenid_success, deleteopenid_failure,
+                redirect_to) 
     
-    form = DeleteForm(user=u)
+    form = DeleteForm(user=user_)
 
     msg = request.GET.get('msg','')
-    return render('authopenid/delete.html', {'form': form, 'msg': msg, },
-                                        context_instance=RequestContext(request))
+    return render('authopenid/delete.html', {
+        'form': form, 
+        'msg': msg, 
+        }, context_instance=RequestContext(request))
 delete = login_required(delete)
 
 def deleteopenid_success(request, identity_url, openid_response):
-    openid=from_openid_response(openid_response)
+    openid_ = from_openid_response(openid_response)
 
-    u = request.user
+    user_ = request.user
     try:
-        o=UserAssociation.objects.get(openid_url__exact=identity_url)
+        uassoc = UserAssociation.objects.get(
+                openid_url__exact=identity_url
+        )
     except:
-        return deleteopenid_failure(request, _("No openid % associated in our database" % identity_url))
+        return deleteopenid_failure(request,
+                _("No openid % associated in our database" % identity_url))
 
-    if o.user.username == request.user.username:
-        u.delete()
+    if uassoc.user.username == user_.username:
+        user_.delete()
         return signout(request)
     else:
-        return deleteopenid_failure(request, _("The openid %s isn't associated to current logged user" % identity_url))
+        return deleteopenid_failure(request,
+                _("The openid %s isn't associated to current logged user" % 
+                    identity_url))
     
-    msg=_("Account deleted.") 
-    redirect="/?msg=%s" % (urlquote_plus(msg))
+    msg = _("Account deleted.") 
+    redirect = "/?msg=%s" % (urlquote_plus(msg))
     return HttpResponseRedirect(redirect)
     
 
 def deleteopenid_failure(request, message):
-    redirect_to="%s?msg=%s" % (reverse('user_delete'), urlquote_plus(message))
+    redirect_to = "%s?msg=%s" % (reverse('user_delete'), urlquote_plus(message))
     return HttpResponseRedirect(redirect_to)
 
 
             new_pw = User.objects.make_random_password()
             confirm_key = UserPasswordQueue.objects.get_new_confirm_key()
             try:
-                q=UserPasswordQueue.objects.get(user=form.user_cache)
+                uqueue = UserPasswordQueue.objects.get(
+                        user=form.user_cache
+                )
             except:
-                q=UserPasswordQueue(user=form.user_cache)
-            q.new_password=new_pw
-            q.confirm_key = confirm_key
-            q.save()
+                uqueue = UserPasswordQueue(
+                        user=form.user_cache
+                )
+            uqueue.new_password = new_pw
+            uqueue.confirm_key = confirm_key
+            uqueue.save()
             # send email 
             current_domain = Site.objects.get_current().domain
             subject = _("Request for a new password")
-            message_template = loader.get_template('authopenid/sendpw_email.txt')
-            message_context = Context({ 'site_url': 'http://%s' % current_domain,
+            message_template = loader.get_template(
+                    'authopenid/sendpw_email.txt')
+            message_context = Context({ 
+                'site_url': 'http://%s' % current_domain,
                 'confirm_key': confirm_key,
                 'username': form.user_cache.username,
                 'password': new_pw,
                 'url_confirm': reverse('user_confirmchangepw'),
             })
             message = message_template.render(message_context)
-            send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [form.user_cache.email])
-            msg=_("A new password has been sent to your email")
+            send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, 
+                    [form.user_cache.email])
+            msg = _("A new password has been sent to your email")
     else:
         form = EmailPasswordForm()
         
-    return render('authopenid/sendpw.html', {'form': form,
-            'msg': msg, },
-            context_instance=RequestContext(request))
+    return render('authopenid/sendpw.html', {
+        'form': form,
+        'msg': msg 
+        }, context_instance=RequestContext(request))
 
 
 def confirmchangepw(request):
     url : /sendpw/confirm/?key
 
     """
-
-
     confirm_key = request.GET.get('key', '')
     if not confirm_key:
         return HttpResponseRedirect('/')
 
     try:
-        q = UserPasswordQueue.objects.get(confirm_key__exact=confirm_key)
+        uqueue = UserPasswordQueue.objects.get(
+                confirm_key__exact=confirm_key
+        )
     except:
-        msg=_("Can not change password. Confirmation key '%s' isn't registered." % confirm_key) 
-        redirect="%s?msg=%s" % (reverse('user_sendpw'),urlquote_plus(msg))
+        msg = _("Can not change password. Confirmation key '%s'\
+                isn't registered." % confirm_key) 
+        redirect = "%s?msg=%s" % (
+                reverse('user_sendpw'), urlquote_plus(msg))
         return HttpResponseRedirect(redirect)
 
     try:
-        user = User.objects.get(id=q.user.id)
+        user_ = User.objects.get(id=uqueue.user.id)
     except:
-        msg=_("Can not change password. User don't exist anymore in our database.") 
-        redirect="%s?msg=%s" % (reverse('user_sendpw'),urlquote_plus(msg))
+        msg = _("Can not change password. User don't exist anymore \
+                in our database.") 
+        redirect = "%s?msg=%s" % (reverse('user_sendpw'), 
+                urlquote_plus(msg))
         return HttpResponseRedirect(redirect)
 
-    user.set_password(q.new_password)
-    user.save()
-    q.delete()
-    msg=_("Password changed for %s. You could now sign-in" % user.username) 
-    redirect="%s?msg=%s" % (reverse('user_signin'), 
+    user_.set_password(uqueue.new_password)
+    user_.save()
+    uqueue.delete()
+    msg = _("Password changed for %s. You could now sign-in" % 
+            user_.username) 
+    redirect = "%s?msg=%s" % (reverse('user_signin'), 
                                         urlquote_plus(msg))
 
     return HttpResponseRedirect(redirect)
+[MASTER]
+profile=no
+ignore=.svn
+persistent=yes
+cache-size=500
+
+[REPORTS]
+output-format=colorized
+include-ids=y
+evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
+comment=no
+
+[FORMAT]
+max-line-length=80
+
+
+[BASIC]
+
+# Regular expression which should only match functions or classes name which do
+# not require a docstring
+no-docstring-rgx=__.*__
+
+# Regular expression which should only match correct module names
+module-rgx=[a-z_][a-z0-9_]*$
+
+# Regular expression which should only match correct module level names
+const-rgx=(([a-z_][a-z0-9_]{3,30})|(__.*__)|([A-Z_][A-Z0-9_]{3,30}))$
+
+# Regular expression which should only match correct class names
+class-rgx=[A-Z_][a-zA-Z0-9]+$
+
+# Regular expression which should only match correct function names
+function-rgx=[a-z_][A-Za-z0-9_]{2,30}$
+
+# Regular expression which should only match correct method names
+method-rgx=[a-z_][A-Za-z0-9_]{2,30}$
+
+# Regular expression which should only match correct list comprehension /
+# generator expression variable names
+inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
+
+# Good variable names which should always be accepted, separated by a comma
+good-names=i,j,k,ex,Run,_
+
+# Bad variable names which should always be refused, separated by a comma
+bad-names=foo,bar,baz,toto,tutu,tata
+
+# List of builtins function names that should not be used, separated by a comma
+bad-functions=input
+
+[MESSAGES CONTROL]
+# Disable the message(s) with the given id(s).
+#
+# E0611: No name in module -- pylint gives too many false positives
+#        from orca/scripts/*.py files.
+#
+# W0102: Default argument is a mutable value (list or dictionary)
+# W0141: Used builtin function 'map'
+# W0403: Relative import
+# W0511: Warning note (FIXME or XXX) detected.
+# W0603: Using the global statement
+# W0612: Unused variable
+# W0613: Unused argument
+# W0702: No exception's type specified
+# W0704: Except doesn't do anything
+# C0111: Missing docstring
+# C0302: Module has too much lines
+# R0201: could be a function
+# R0401: Cyclic import between two or more modules detected
+# R0801: Similar lines detected among multiple files
+# R0902: Class has too many instance attributes
+# R0903: Class has too few public methods
+# R0904: Class has too many public methods
+# R0911: Function or method has too many return statements
+# R0912: Function or method has too many branches
+# R0913: Function or method takes too many arguments
+# R0914: Function or method has too many local variables
+# R0915: Function or method has too many statements
+#
+disable-msg=E0611,C0111,R0201,W0102,W0141,W0403,W0603,W0612,W0613,W0702,W0704,W0511,R0801,R0912,R0915,R0914,R0904,R0903,R0401,R0911,R0913,C0302,R0902
+
+