"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Products/PageTemplates/Expressions.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.

Expressions.py  (Zope-5.2):Expressions.py  (Zope-5.2.1)
skipping to change at line 24 skipping to change at line 24
Page Template-specific implementation of TALES, with handlers Page Template-specific implementation of TALES, with handlers
for Python expressions, string literals, and paths. for Python expressions, string literals, and paths.
""" """
import logging import logging
import warnings import warnings
import OFS.interfaces import OFS.interfaces
from AccessControl import safe_builtins from AccessControl import safe_builtins
from AccessControl.SecurityManagement import getSecurityManager
from Acquisition import aq_base from Acquisition import aq_base
from MultiMapping import MultiMapping from MultiMapping import MultiMapping
from zExceptions import NotFound from zExceptions import NotFound
from zExceptions import Unauthorized from zExceptions import Unauthorized
from zope.component import queryUtility from zope.component import queryUtility
from zope.contentprovider.tales import TALESProviderExpression from zope.contentprovider.tales import TALESProviderExpression
from zope.i18n import translate from zope.i18n import translate
from zope.interface import implementer from zope.interface import implementer
from zope.pagetemplate.engine import ZopeEngine as Z3Engine from zope.pagetemplate.engine import ZopeEngine as Z3Engine
from zope.proxy import removeAllProxies from zope.proxy import removeAllProxies
skipping to change at line 71 skipping to change at line 72
ZopeUndefs = Undefs + (NotFound, Unauthorized) ZopeUndefs = Undefs + (NotFound, Unauthorized)
def boboAwareZopeTraverse(object, path_items, econtext): def boboAwareZopeTraverse(object, path_items, econtext):
"""Traverses a sequence of names, first trying attributes then items. """Traverses a sequence of names, first trying attributes then items.
This uses zope.traversing path traversal where possible and interacts This uses zope.traversing path traversal where possible and interacts
correctly with objects providing OFS.interface.ITraversable when correctly with objects providing OFS.interface.ITraversable when
necessary (bobo-awareness). necessary (bobo-awareness).
""" """
request = getattr(econtext, 'request', None) request = getattr(econtext, 'request', None)
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 OFS.interfaces.ITraversable.providedBy(object): if OFS.interfaces.ITraversable.providedBy(object):
object = object.restrictedTraverse(name) object = object.restrictedTraverse(name)
else: else:
object = traversePathElement(object, name, path_items, found = traversePathElement(object, name, path_items,
request=request) request=request)
# 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)
object = 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(object, object, name, found)
object = found
except Unauthorized:
# Convert Unauthorized to prevent information disclosures
raise NotFound(name)
return object return object
def trustedBoboAwareZopeTraverse(object, path_items, econtext): def trustedBoboAwareZopeTraverse(object, path_items, econtext):
"""Traverses a sequence of names, first trying attributes then items. """Traverses a sequence of names, first trying attributes then items.
This uses zope.traversing path traversal where possible and interacts This uses zope.traversing path traversal where possible and interacts
correctly with objects providing OFS.interface.ITraversable when correctly with objects providing OFS.interface.ITraversable when
necessary (bobo-awareness). necessary (bobo-awareness).
""" """
request = getattr(econtext, 'request', None) request = getattr(econtext, 'request', None)
 End of changes. 4 change blocks. 
9 lines changed or deleted 29 lines changed or added

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