[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/authentication/ Use
enumerate() where possible
Dmitry Vasiliev
dima at hlabs.spb.ru
Thu Aug 25 09:34:02 EDT 2005
Log message for revision 38084:
Use enumerate() where possible
Changed:
U Zope3/trunk/src/zope/app/authentication/groupfolder.py
U Zope3/trunk/src/zope/app/authentication/principalfolder.py
-=-
Modified: Zope3/trunk/src/zope/app/authentication/groupfolder.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/groupfolder.py 2005-08-24 23:46:04 UTC (rev 38083)
+++ Zope3/trunk/src/zope/app/authentication/groupfolder.py 2005-08-25 13:34:02 UTC (rev 38084)
@@ -178,10 +178,9 @@
""" Search for groups"""
search = query.get('search')
if search is not None:
- i = 0
n = 0
search = search.lower()
- for id, groupinfo in self.items():
+ for i, (id, groupinfo) in enumerate(self.items()):
if (search in groupinfo.title.lower() or
(groupinfo.description and
search in groupinfo.description.lower())):
@@ -189,8 +188,7 @@
or
(batch_size is not None and n >= batch_size)):
n += 1
- yield self.prefix+id
- i += 1
+ yield self.prefix + id
def authenticateCredentials(self, credentials):
# user folders don't authenticate
Modified: Zope3/trunk/src/zope/app/authentication/principalfolder.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/principalfolder.py 2005-08-24 23:46:04 UTC (rev 38083)
+++ Zope3/trunk/src/zope/app/authentication/principalfolder.py 2005-08-25 13:34:02 UTC (rev 38084)
@@ -244,9 +244,8 @@
if search is None:
return
search = search.lower()
- i = 0
n = 1
- for value in self.values():
+ for i, value in enumerate(self.values()):
if (search in value.title.lower() or
search in value.description.lower() or
search in value.login.lower()):
@@ -254,7 +253,6 @@
or (batch_size is not None and n > batch_size)):
n += 1
yield self.prefix + value.__name__
- i += 1
class Principal(object):
More information about the Zope3-Checkins
mailing list