Commit afb0beb0 authored by Evan Simpson's avatar Evan Simpson

Fix incompatibilities and attribution

parent 2c4d2864
...@@ -4,10 +4,13 @@ ZTUtils changes ...@@ -4,10 +4,13 @@ ZTUtils changes
Change information for previous versions can be found in the Change information for previous versions can be found in the
file HISTORY.txt. file HISTORY.txt.
Version 1.1.0 Version 1.1.1
Features Added 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 - TreeMakers have a setChildAccess() method that you can use
to control tree construction. Child nodes can be accessed to control tree construction. Child nodes can be accessed
through either an attribute name or callback function. through either an attribute name or callback function.
...@@ -38,3 +41,4 @@ ZTUtils changes ...@@ -38,3 +41,4 @@ ZTUtils changes
Bugs Fixed Bugs Fixed
- Version 1.1.0 broke on Python 1.5.2 and Zope <2.4
...@@ -84,20 +84,31 @@ ...@@ -84,20 +84,31 @@
############################################################################## ##############################################################################
__doc__='''Zope-specific versions of ZTUTils classes __doc__='''Zope-specific versions of ZTUTils classes
$Id: Zope.py,v 1.2 2001/08/13 18:15:34 evan Exp $''' $Id: Zope.py,v 1.3 2001/08/16 17:42:53 evan Exp $'''
__version__='$Revision: 1.2 $'[11:-2] __version__='$Revision: 1.3 $'[11:-2]
import sys, cgi, urllib, cgi import sys, cgi, urllib, cgi
from Tree import encodeExpansion, decodeExpansion, TreeMaker from Tree import encodeExpansion, decodeExpansion, TreeMaker
from SimpleTree import SimpleTreeMaker from SimpleTree import SimpleTreeMaker
from Batch import Batch from Batch import Batch
from Products.ZCatalog.Lazy import Lazy from Products.ZCatalog.Lazy import Lazy
from AccessControl.ZopeGuards import guarded_getitem from AccessControl import getSecurityManager
from AccessControl import getSecurityManager, Unauthorized
from string import split, join from string import split, join
from types import StringType, ListType, IntType, FloatType from types import StringType, ListType, IntType, FloatType
from DateTime import DateTime 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): class LazyFilter(Lazy):
# A LazyFilter that checks with the security policy # A LazyFilter that checks with the security policy
...@@ -128,24 +139,27 @@ class LazyFilter(Lazy): ...@@ -128,24 +139,27 @@ class LazyFilter(Lazy):
e=self._eindex e=self._eindex
skip = self._skip skip = self._skip
while i > ind: while i > ind:
e = e + 1
try: try:
e=e+1
try: v = guarded_getitem(s, e) try: v = guarded_getitem(s, e)
except Unauthorized, vv: except 'Unauthorized', vv:
if skip is None: if skip is None:
msg = '(item %s): %s' % (index, vv) msg = '(item %s): %s' % (index, vv)
raise Unauthorized, msg, sys.exc_info()[2] raise Unauthorized, msg, sys.exc_info()[2]
continue skip_this = 1
if skip and not getSecurityManager().checkPermission(skip, v): else:
continue skip_this = 0
if test is None or test(v):
data.append(v)
ind=ind+1
except IndexError: except IndexError:
del self._test del self._test
del self._seq del self._seq
del self._eindex del self._eindex
raise IndexError, index 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 self._eindex=e
return data[i] 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