diff rhodecode/model/validators.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 af96fb19b53a
children 802c94bdfc85
line wrap: on
line diff
--- a/rhodecode/model/validators.py	Thu Mar 28 01:10:45 2013 +0100
+++ b/rhodecode/model/validators.py	Thu Mar 28 01:10:45 2013 +0100
@@ -280,7 +280,7 @@
 
             if not authenticate(username, password):
                 user = User.get_by_username(username)
-                if user and user.active is False:
+                if user and not user.active:
                     log.warning('user %s is disabled' % username)
                     msg = M(self, 'disabled_account', state)
                     raise formencode.Invalid(msg, value, state,
@@ -503,7 +503,7 @@
                         error_dict=dict(repo_type=msg)
                     )
                 ## check if we can write to root location !
-                elif gr is None and can_create_repos() is False:
+                elif gr is None and not can_create_repos():
                     msg = M(self, 'permission_denied_root', state)
                     raise formencode.Invalid(msg, value, state,
                         error_dict=dict(repo_type=msg)
@@ -533,7 +533,7 @@
                 #we can create in root, we're fine no validations required
                 return
 
-            forbidden_in_root = gr is None and can_create_in_root is False
+            forbidden_in_root = gr is None and not can_create_in_root
             val = HasReposGroupPermissionAny('group.admin')
             forbidden = not val(gr_name, 'can create group validator')
             if forbidden_in_root or forbidden: