"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Products/PageTemplates/expression.py" between
Zope-5.2.tar.gz and Zope-5.2.1.tar.gz

About: Zope Z Object Publishing Environment - web application platform used for building content management systems, intranets, portals, and custom applications.

expression.py  (Zope-5.2):expression.py  (Zope-5.2.1)
skipping to change at line 13 skipping to change at line 13
import warnings import warnings
from ast import NodeTransformer from ast import NodeTransformer
from ast import parse from ast import parse
from chameleon.astutil import Static from chameleon.astutil import Static
from chameleon.astutil import Symbol from chameleon.astutil import Symbol
from chameleon.codegen import template from chameleon.codegen import template
from chameleon.tales import NotExpr from chameleon.tales import NotExpr
from chameleon.tales import StringExpr from chameleon.tales import StringExpr
from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.ZopeGuards import guarded_apply from AccessControl.ZopeGuards import guarded_apply
from AccessControl.ZopeGuards import guarded_getattr from AccessControl.ZopeGuards import guarded_getattr
from AccessControl.ZopeGuards import guarded_getitem from AccessControl.ZopeGuards import guarded_getitem
from AccessControl.ZopeGuards import guarded_iter from AccessControl.ZopeGuards import guarded_iter
from AccessControl.ZopeGuards import protected_inplacevar from AccessControl.ZopeGuards import protected_inplacevar
from OFS.interfaces import ITraversable from OFS.interfaces import ITraversable
from RestrictedPython import RestrictingNodeTransformer from RestrictedPython import RestrictingNodeTransformer
from RestrictedPython.Utilities import utility_builtins from RestrictedPython.Utilities import utility_builtins
from z3c.pt import expressions from z3c.pt import expressions
from zExceptions import NotFound from zExceptions import NotFound
skipping to change at line 57 skipping to change at line 58
class BoboAwareZopeTraverse: class BoboAwareZopeTraverse:
traverse_method = 'restrictedTraverse' traverse_method = 'restrictedTraverse'
__slots__ = () __slots__ = ()
@classmethod @classmethod
def traverse(cls, base, request, path_items): def traverse(cls, base, request, path_items):
"""See ``zope.app.pagetemplate.engine``.""" """See ``zope.app.pagetemplate.engine``."""
validate = getSecurityManager().validate
path_items = list(path_items) path_items = list(path_items)
path_items.reverse() path_items.reverse()
while path_items: while path_items:
name = path_items.pop() name = path_items.pop()
if name == '_':
warnings.warn('Traversing to the name `_` is deprecated '
'and will be removed in Zope 6.',
DeprecationWarning)
elif name.startswith('_'):
raise NotFound(name)
if ITraversable.providedBy(base): if ITraversable.providedBy(base):
base = getattr(base, cls.traverse_method)(name) base = getattr(base, cls.traverse_method)(name)
else: else:
base = traversePathElement(base, name, path_items, found = traversePathElement(base, name, path_items,
request=request) request=request)
# If traverse_method is something other than
# ``restrictedTraverse`` then traversal is assumed to be
# unrestricted. This emulates ``unrestrictedTraverse``
if cls.traverse_method != 'restrictedTraverse':
base = found
continue
# Special backwards compatibility exception for the name ``_``,
# which was often used for translation message factories.
# Allow and continue traversal.
if name == '_':
warnings.warn('Traversing to the name `_` is deprecated '
'and will be removed in Zope 6.',
DeprecationWarning)
base = found
continue
# All other names starting with ``_`` are disallowed.
# This emulates what restrictedTraverse does.
if name.startswith('_'):
raise NotFound(name)
# traversePathElement doesn't apply any Zope security policy,
# so we validate access explicitly here.
try:
validate(base, base, name, found)
base = found
except Unauthorized:
# Convert Unauthorized to prevent information disclosures
raise NotFound(name)
return base return base
def __call__(self, base, econtext, call, path_items): def __call__(self, base, econtext, call, path_items):
request = econtext.get('request') request = econtext.get('request')
if path_items: if path_items:
base = self.traverse(base, request, path_items) base = self.traverse(base, request, path_items)
if call is False: if call is False:
 End of changes. 4 change blocks. 
9 lines changed or deleted 35 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)