##// END OF EJS Templates
auth: use single instance of auth checker to speed up execution of the permissions check by not creating new instance in each loop iteration.
marcink -
r4142:79ad8339 default
parent child Browse files
Show More
@@ -126,7 +126,7 b' class _PermCheckIterator(object):'
126 self.obj_list = obj_list
126 self.obj_list = obj_list
127 self.obj_attr = obj_attr
127 self.obj_attr = obj_attr
128 self.perm_set = perm_set
128 self.perm_set = perm_set
129 self.perm_checker = perm_checker
129 self.perm_checker = perm_checker(*self.perm_set)
130 self.extra_kwargs = extra_kwargs or {}
130 self.extra_kwargs = extra_kwargs or {}
131
131
132 def __len__(self):
132 def __len__(self):
@@ -136,11 +136,10 b' class _PermCheckIterator(object):'
136 return '<%s (%s)>' % (self.__class__.__name__, self.__len__())
136 return '<%s (%s)>' % (self.__class__.__name__, self.__len__())
137
137
138 def __iter__(self):
138 def __iter__(self):
139 checker = self.perm_checker(*self.perm_set)
140 for db_obj in self.obj_list:
139 for db_obj in self.obj_list:
141 # check permission at this level
140 # check permission at this level
142 name = getattr(db_obj, self.obj_attr, None)
141 name = getattr(db_obj, self.obj_attr, None)
143 if not checker(name, self.__class__.__name__, **self.extra_kwargs):
142 if not self.perm_checker(name, self.__class__.__name__, **self.extra_kwargs):
144 continue
143 continue
145
144
146 yield db_obj
145 yield db_obj
General Comments 0
You need to be logged in to leave comments. Login now