diff rhodecode/lib/middleware/simplegit.py @ 3625:260a7a01b054 beta

follow Python conventions for boolean values True and False might be singletons and the "default" values for "boolean" expressions, but "all" values in Python has a boolean value and should be evaluated as such. Checking with 'is True' and 'is False' is thus confusing, error prone and unnessarily complex. If we anywhere rely and nullable boolean fields from the database layer and don't want the null value to be treated as False then we should check explicitly for null with 'is None'.
author Mads Kiilerich <madski@unity3d.com>
date Thu, 28 Mar 2013 01:10:45 +0100
parents 11feddcd75bb
children 10b4e34841a4
line wrap: on
line diff
--- a/rhodecode/lib/middleware/simplegit.py	Thu Mar 28 01:10:45 2013 +0100
+++ b/rhodecode/lib/middleware/simplegit.py	Thu Mar 28 01:10:45 2013 +0100
@@ -126,7 +126,7 @@
             return HTTPInternalServerError()(environ, start_response)
 
         # quick check if that dir exists...
-        if is_valid_repo(repo_name, self.basepath, 'git') is False:
+        if not is_valid_repo(repo_name, self.basepath, 'git'):
             return HTTPNotFound()(environ, start_response)
 
         #======================================================================
@@ -143,11 +143,11 @@
             anonymous_perm = self._check_permission(action, anonymous_user,
                                                     repo_name, ip_addr)
 
-            if anonymous_perm is not True or anonymous_user.active is False:
-                if anonymous_perm is not True:
+            if not anonymous_perm or not anonymous_user.active:
+                if not anonymous_perm:
                     log.debug('Not enough credentials to access this '
                               'repository as anonymous user')
-                if anonymous_user.active is False:
+                if not anonymous_user.active:
                     log.debug('Anonymous access is disabled, running '
                               'authentication')
                 #==============================================================
@@ -184,7 +184,7 @@
 
                 #check permissions for this repository
                 perm = self._check_permission(action, user, repo_name, ip_addr)
-                if perm is not True:
+                if not perm:
                     return HTTPForbidden()(environ, start_response)
 
         # extras are injected into UI object and later available