[ZPT] CVS: Packages/ZTUtils - CHANGES.txt:1.2 Zope.py:1.3

Evan Simpson evan@zope.com
Thu, 16 Aug 2001 13:42:54 -0400


Update of /cvs-repository/Packages/ZTUtils
In directory cvs.zope.org:/tmp/cvs-serv29966

Modified Files:
	CHANGES.txt Zope.py 
Log Message:
Fix incompatibilities and attribution


=== Packages/ZTUtils/CHANGES.txt 1.1 => 1.2 ===
   file HISTORY.txt.
 
-    Version 1.1.0
+    Version 1.1.1
 
       Features Added
 
+        - Used an algorithm submitted by Tino Wildenhain to add
+          Roman numeral support to Iterators.
+
         - TreeMakers have a setChildAccess() method that you can use
           to control tree construction.  Child nodes can be accessed
           through either an attribute name or callback function.
@@ -38,3 +41,4 @@
 
       Bugs Fixed
 
+        - Version 1.1.0 broke on Python 1.5.2 and Zope <2.4


=== Packages/ZTUtils/Zope.py 1.2 => 1.3 ===
 from Batch import Batch
 from Products.ZCatalog.Lazy import Lazy
-from AccessControl.ZopeGuards import guarded_getitem
-from AccessControl import getSecurityManager, Unauthorized
+from AccessControl import getSecurityManager
 from string import split, join
 from types import StringType, ListType, IntType, FloatType
 from DateTime import DateTime
 
+try:
+    from AccessControl.ZopeGuards import guarded_getitem
+except ImportError:
+    Unauthorized = 'Unauthorized'
+    def guarded_getitem(object, index):
+        v = object[index]
+        if getSecurityManager().validate(object, object, index, v):
+            return v
+        raise Unauthorized, 'unauthorized access to element %s' % `i`
+else:
+    from AccessControl import Unauthorized
+
 class LazyFilter(Lazy):
     # A LazyFilter that checks with the security policy
 
@@ -128,24 +139,27 @@
         e=self._eindex
         skip = self._skip
         while i > ind:
+            e = e + 1
             try:
-                e=e+1
                 try: v = guarded_getitem(s, e)
-                except Unauthorized, vv:
+                except 'Unauthorized', vv:
                     if skip is None:
                         msg = '(item %s): %s' % (index, vv)
                         raise Unauthorized, msg, sys.exc_info()[2]
-                    continue
-                if skip and not getSecurityManager().checkPermission(skip, v):
-                    continue
-                if test is None or test(v):
-                    data.append(v)
-                    ind=ind+1
+                    skip_this = 1
+                else:
+                    skip_this = 0
             except IndexError:
                 del self._test
                 del self._seq
                 del self._eindex
                 raise IndexError, index
+            if skip_this: continue
+            if skip and not getSecurityManager().checkPermission(skip, v):
+                continue
+            if test is None or test(v):
+                data.append(v)
+                ind=ind+1
         self._eindex=e
         return data[i]