[Zope3-checkins] CVS: Zope3/src/zope/security - checker.py:1.39
Jim Fulton
jim at zope.com
Tue Sep 2 17:47:23 EDT 2003
Update of /cvs-repository/Zope3/src/zope/security
In directory cvs.zope.org:/tmp/cvs-serv17338/src/zope/security
Modified Files:
checker.py
Log Message:
Added a repr to Global objects.
Added a function for getting module checkers.
Changed the default security declaration for modules to expose only
__name__. It's unclear why __name__ is needed, but there's a test that
depends on it.
=== Zope3/src/zope/security/checker.py 1.38 => 1.39 ===
--- Zope3/src/zope/security/checker.py:1.38 Fri Aug 15 15:49:55 2003
+++ Zope3/src/zope/security/checker.py Tue Sep 2 16:47:22 2003
@@ -482,6 +482,10 @@
def __reduce__(self):
return self.__name__
+ def __repr__(self):
+ return "%s(%s,%s)" % (self.__class__.__name__,
+ self.__name__, self.__module__)
+
CheckerPublic = Global('CheckerPublic')
# Now we wrap it in a security proxy so that it retains it's
@@ -641,8 +645,8 @@
return _typeChecker
-def _moduleChecker(module):
- return _checkers.get(module, _typeChecker)
+def moduleChecker(module):
+ return _checkers.get(module)
# The variable '_always_available' should really be called
@@ -658,6 +662,7 @@
_callableChecker = NamesChecker(['__str__', '__name__', '__call__'])
_typeChecker = NamesChecker(
['__str__', '__name__', '__module__', '__bases__', '__mro__'])
+_namedChecker = NamesChecker(['__name__'])
_iteratorChecker = NamesChecker(['next', '__iter__'])
@@ -676,6 +681,7 @@
datetime.date: NoProxy,
datetime.time: NoProxy,
}
+
# Available for tests. Located here so it can be kept in sync with BasicTypes.
BasicTypes_examples = {
object: object(),
@@ -726,7 +732,7 @@
types.BuiltinMethodType: _callableChecker,
type(().__getslice__): _callableChecker, # slot description
type: _typeChecker,
- types.ModuleType: _moduleChecker,
+ types.ModuleType: lambda module: _checkers.get(module, _namedChecker),
type(iter([])): _iteratorChecker, # Same types in Python 2.2.1,
type(iter(())): _iteratorChecker, # different in Python 2.3.
type(iter({})): _iteratorChecker,
More information about the Zope3-Checkins
mailing list