cleanup and micro-optimization stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 29 Sep 2010 12:54:35 +0200
branchstable
changeset 6364 ad9ed9803eb6
parent 6363 b9ec8ebc187a
child 6365 a15cc5e16178
cleanup and micro-optimization
selectors.py
server/test/unittest_repository.py
--- a/selectors.py	Wed Sep 29 12:53:30 2010 +0200
+++ b/selectors.py	Wed Sep 29 12:54:35 2010 +0200
@@ -1073,7 +1073,9 @@
                 for i, row in enumerate(rset):
                     if not rset.description[i][col] in need_local_check:
                         continue
-                    if not self.score(req, rset, i, col):
+                    # micro-optimisation instead of calling self.score(req,
+                    # rset, i, col): rset may be large
+                    if not rset.get_entity(i, col).cw_has_perm(action):
                         return 0
                 score += 1
             return score
--- a/server/test/unittest_repository.py	Wed Sep 29 12:53:30 2010 +0200
+++ b/server/test/unittest_repository.py	Wed Sep 29 12:54:35 2010 +0200
@@ -158,7 +158,7 @@
 
     def test_rollback_on_execute_unauthorized(self):
         class UnauthorizedAfterHook(Hook):
-            __regid__ = 'valerror-after-hook'
+            __regid__ = 'unauthorized-after-hook'
             __select__ = Hook.__select__ & is_instance('CWGroup')
             events = ('after_update_entity',)
             def __call__(self):