[Zope3-checkins] CVS: Zope3/src/zope/app/browser/security - permissionwidget.py:1.3
Jim Fulton
jim@zope.com
Tue, 21 Jan 2003 16:22:32 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/security
In directory cvs.zope.org:/tmp/cvs-serv10458
Modified Files:
permissionwidget.py
Log Message:
Changed permission fields to use permission ids, rather than permission objects
=== Zope3/src/zope/app/browser/security/permissionwidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/browser/security/permissionwidget.py:1.2 Wed Dec 25 09:12:34 2002
+++ Zope3/src/zope/app/browser/security/permissionwidget.py Tue Jan 21 16:22:00 2003
@@ -23,15 +23,13 @@
class BaseWidget:
def _convert(self, permission_id):
- if not permission_id:
- return None
- service = getService(self.context.context, "Permissions")
- return service.getPermission(permission_id)
+ if type(permission_id) is unicode:
+ try:
+ permission_id = permission_id.encode('ascii')
+ except UnicodeError, v:
+ raise ConversionError("Invalid textual data", v)
- def _unconvert(self, permission):
- if permission is None:
- return None
- return permission.getId()
+ return permission_id
class SinglePermissionWidget(BaseWidget, widget.BrowserWidget):
@@ -40,14 +38,12 @@
search_string = self.request.form.get(search_name, '')
service = getService(self.context.context, "Permissions")
- permissions = list(service.getPermissions())
- permissions.sort(lambda x,y: cmp(x.getId(), y.getId()))
- permissions = map(self._unconvert, permissions)
+ permissions = [p.getId() for p in service.getPermissions()]
+ permissions.sort()
if search_string:
permissions = [permission
for permission in permissions
if permission.find(search_string)!=-1]
- permissions.sort()
select_name = self.name
selected = self._showData()