Skip to content

Commit

Permalink
OFS.Traversable: use globalrequest
Browse files Browse the repository at this point in the history
In OFS.Traversable, use ``zope.globalrequest.getRequest`` throughout instead of acquiring the request.
  • Loading branch information
thet committed Apr 15, 2018
1 parent e8598cf commit c0f916a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ https://github.com/zopefoundation/Zope/blob/4.0a6/CHANGES.rst
4.0b4 (unreleased)
------------------

- In OFS.Traversable, use ``zope.globalrequest.getRequest`` throughout instead of acquiring the request.

- Fix an edge case where the data which was set using ``response.write()`` was
not returned by ``publish_module`` (#256).

Expand Down
12 changes: 6 additions & 6 deletions src/OFS/Traversable.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from AccessControl.unauthorized import Unauthorized
from AccessControl.ZopeGuards import guarded_getattr
from Acquisition import Acquired
from Acquisition import aq_acquire
from Acquisition import aq_base
from Acquisition import aq_inner
from Acquisition import aq_parent
Expand All @@ -31,6 +30,7 @@
from ZPublisher.interfaces import UseTraversalDefault
from ZODB.POSException import ConflictError

from zope.globalrequest import getRequest
from zope.interface import implementer
from zope.interface import Interface
from zope.component import queryMultiAdapter
Expand Down Expand Up @@ -69,7 +69,7 @@ def absolute_url(self, relative=0):
spp = self.getPhysicalPath()

try:
toUrl = aq_acquire(self, 'REQUEST').physicalPathToURL
toUrl = getRequest().physicalPathToURL
except AttributeError:
return path2url(spp[1:])
return toUrl(spp)
Expand All @@ -83,7 +83,7 @@ def absolute_url_path(self):
"""
spp = self.getPhysicalPath()
try:
toUrl = aq_acquire(self, 'REQUEST').physicalPathToURL
toUrl = getRequest().physicalPathToURL
except AttributeError:
return path2url(spp) or '/'
return toUrl(spp, relative=1) or '/'
Expand All @@ -98,7 +98,7 @@ def virtual_url_path(self):
"""
spp = self.getPhysicalPath()
try:
toVirt = aq_acquire(self, 'REQUEST').physicalPathToVirtualPath
toVirt = getRequest().physicalPathToVirtualPath
except AttributeError:
return path2url(spp[1:])
return path2url(toVirt(spp))
Expand Down Expand Up @@ -227,7 +227,7 @@ def unrestrictedTraverse(self, path, default=_marker, restricted=False):
ns, nm = nsParse(name)
try:
next = namespaceLookup(
ns, nm, obj, aq_acquire(self, 'REQUEST'))
ns, nm, obj, getRequest())
if IAcquirer.providedBy(next):
next = next.__of__(obj)
if restricted and not validate(
Expand Down Expand Up @@ -311,7 +311,7 @@ def unrestrictedTraverse(self, path, default=_marker, restricted=False):
except (AttributeError, NotFound, KeyError) as e:
# Try to look for a view
next = queryMultiAdapter(
(obj, aq_acquire(self, 'REQUEST')),
(obj, getRequest()),
Interface, name)

if next is not None:
Expand Down

0 comments on commit c0f916a

Please sign in to comment.