[Zope-Checkins] CVS: Zope/lib/python/AccessControl - Role.py:1.50.22.1 User.py:1.157.2.1
Matthew T. Kromer
matt@zope.com
Fri, 28 Sep 2001 14:38:43 -0400
Update of /cvs-repository/Zope/lib/python/AccessControl
In directory cvs.zope.org:/tmp/cvs-serv14607
Modified Files:
Tag: matt-userfolder-apiext
Role.py User.py
Log Message:
Tacks a 'max user to list' field in acl_users properties, when list size
is exceeded, displays a text box rather than a list for local role assignment.
=== Zope/lib/python/AccessControl/Role.py 1.50 => 1.50.22.1 ===
from Permission import Permission
from App.Common import aq_base
+from exceptions import *
ListType=type([])
@@ -374,14 +375,24 @@
def get_valid_userids(self):
item=self
dict={}
+ _notfound = []
while 1:
- if hasattr(aq_base(item), 'acl_users') and \
- hasattr(item.acl_users, 'user_names'):
- for name in item.acl_users.user_names():
- dict[name]=1
- if not hasattr(item, 'aq_parent'):
+ aclu = getattr(aq_base(item), 'acl_users', _notfound)
+ if aclu is not _notfound:
+ mlu = getattr(aclu, 'maxlistusers', _notfound)
+ if type(mlu) != type(1): mlu = 0
+ if mlu < 0: raise OverflowError
+ un = getattr(aclu, 'user_names', _notfound)
+ if un is not _notfound:
+ unl = un()
+ # maxlistusers of 0 is list all
+ if len(unl) > mlu and mlu != 0:
+ raise OverflowError
+ for name in un():
+ dict[name]=1
+ item = getattr(item, 'aq_parent', _notfound)
+ if item is _notfound:
break
- item=item.aq_parent
keys=dict.keys()
keys.sort()
return tuple(keys)
=== Zope/lib/python/AccessControl/User.py 1.157 => 1.157.2.1 ===
isPrincipiaFolderish=1
isAUserFolder=1
+ maxlistusers = 0
encrypt_passwords = 0
@@ -795,11 +796,16 @@
management_view='Properties')
def manage_setUserFolderProperties(self, encrypt_passwords=0,
- update_passwords=0, REQUEST=None):
+ update_passwords=0, maxlistusers=0,
+ REQUEST=None):
"""
Sets the properties of the user folder.
"""
self.encrypt_passwords = not not encrypt_passwords
+ try:
+ self.maxlistusers = int(maxlistusers)
+ except ValueError:
+ self.maxlistusers = 0
if encrypt_passwords and update_passwords:
changed = 0
for u in self.getUsers():