[Zope3-checkins] CVS: Zope3/src/zope/app/component - directiveswithperms.py:1.1.2.4
Steve Alexander
steve@cat-box.net
Sun, 18 May 2003 17:20:27 -0400
Update of /cvs-repository/Zope3/src/zope/app/component
In directory cvs.zope.org:/tmp/cvs-serv4988/app/component
Modified Files:
Tag: stevea-decorators-branch
directiveswithperms.py
Log Message:
Removed another couple of TODO items by implementing the code.
=== Zope3/src/zope/app/component/directiveswithperms.py 1.1.2.3 => 1.1.2.4 ===
--- Zope3/src/zope/app/component/directiveswithperms.py:1.1.2.3 Sun May 18 17:01:01 2003
+++ Zope3/src/zope/app/component/directiveswithperms.py Sun May 18 17:19:57 2003
@@ -289,19 +289,35 @@
class_ = self._class
names = self._names or []
- # Make a set of names from those appearing in the permission maps,
- # and those in names.
- # We don't really *need* to do this, but it makes the names attribute
- # of the DecoratorSpec ugly.
-
- nameset = dict(zip(names, names)) # don't care about values
- nameset.update(self._get_permission_map)
- nameset.update(self._set_permission_map)
- names = nameset.keys()
+ nameset = dict(zip(names, names)) # treat as set; ignore values
+
+ # Check that neither __Security_checker__ nor __providedBy__ are
+ # given as names.
+ if '__Security_checker__' in nameset:
+ raise ConfigurationError(
+ 'The name "__Security_checker__" is reserved.')
+ if '__providedBy__' in nameset:
+ raise ConfigurationError(
+ 'The name "__providedBy__" is reserved.')
+
+ # Filter the permission maps to include permissions only for
+ # names that appear in 'names'.
+
+ get_permission_map = self._get_permission_map
+ set_permission_map = self._set_permission_map
+
+ # NB: Get a copy of keys as we're changing the dict.
+ for name in get_permission_map.keys():
+ if name not in nameset:
+ del get_permission_map[name]
+
+ for name in set_permission_map.keys():
+ if name not in nameset:
+ del set_permission_map[name]
spec = DecoratorSpec(class_, implementedBy(class_), names,
- self._get_permission_map,
- self._set_permission_map,
+ get_permission_map,
+ set_permission_map,
self._trusted_mixin)
return [