Commit afb0beb0 authored by Evan Simpson's avatar Evan Simpson

Fix incompatibilities and attribution

parent 2c4d2864
......@@ -4,10 +4,13 @@ ZTUtils changes
Change information for previous versions can be found in the
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 @@ ZTUtils changes
Bugs Fixed
- Version 1.1.0 broke on Python 1.5.2 and Zope <2.4
......@@ -84,20 +84,31 @@
##############################################################################
__doc__='''Zope-specific versions of ZTUTils classes
$Id: Zope.py,v 1.2 2001/08/13 18:15:34 evan Exp $'''
__version__='$Revision: 1.2 $'[11:-2]
$Id: Zope.py,v 1.3 2001/08/16 17:42:53 evan Exp $'''
__version__='$Revision: 1.3 $'[11:-2]
import sys, cgi, urllib, cgi
from Tree import encodeExpansion, decodeExpansion, TreeMaker
from SimpleTree import SimpleTreeMaker
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 @@ class LazyFilter(Lazy):
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]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment