Commit f67a8b8b authored by Tres Seaver's avatar Tres Seaver

Remove URL-based suppression of access rules and site root objects.

Suppression using ``os.environ`` still works.

Fixes LP #142878.
parent 3caa940b
......@@ -11,6 +11,9 @@ http://docs.zope.org/zope2/releases/.
Bugs Fixed
++++++++++
- LP #142878: Remove URL-based suppression of access rules and site root
objects. Suppression using ``os.environ`` still works.
- LP #143144: Fix documentation for the zope.conf ``mount-point``
directive.
......
......@@ -20,20 +20,8 @@ class AccessRule(NameCaller):
def __call__(self, container, request):
if SUPPRESS_ACCESSRULE:
return
if '_SUPPRESS_ACCESSRULE' in _swallow(request, '_SUPPRESS'):
request.setVirtualRoot(request.steps)
return
NameCaller.__call__(self, container, request)
def _swallow(request, prefix):
path = request['TraversalRequestNameStack']
steps = request.steps
i = len(steps)
while i > 0 and steps[i - 1][:1] == '_':
i = i - 1
while path and path[-1][:len(prefix)] == prefix:
steps.append(path.pop())
return steps[i:]
def manage_addAccessRule(self, method_id=None, REQUEST=None, **ignored):
"""Point a __before_traverse__ entry at the specified method"""
......
......@@ -14,8 +14,6 @@ from ZPublisher.BeforeTraverse import NameCaller
from ZPublisher.BeforeTraverse import registerBeforeTraverse
from ZPublisher.BeforeTraverse import unregisterBeforeTraverse
from Products.SiteAccess.AccessRule import _swallow
SUPPRESS_SITEROOT = os.environ.has_key('SUPPRESS_SITEROOT')
class Traverser(Persistent, Item):
......@@ -103,9 +101,6 @@ class SiteRoot(Traverser, Implicit):
rq = request
if SUPPRESS_SITEROOT:
return
if '_SUPPRESS_SITEROOT' in _swallow(rq, '_SUPPRESS'):
rq.setVirtualRoot(rq.steps)
return
base = (self.base or
rq.get('SiteRootBASE') or
rq.environ.get('SiteRootBASE'))
......
......@@ -37,7 +37,7 @@ class AccessRuleTests(unittest.TestCase):
self.failIf(_called)
def test___call___w_SUPPRESS_ACCESSRULE_in_URL(self):
# This behavior will change once we land lp:142878.
# This behavior changed in landing lp:142878.
_called = []
def _func(*args):
_called.append(args)
......@@ -47,8 +47,8 @@ class AccessRuleTests(unittest.TestCase):
request.steps = []
container = DummyContainer(testing=_func)
rule(container, request)
self.failIf(_called)
self.assertEqual(request._virtual_root, ['_SUPPRESS_ACCESSRULE'])
self.failUnless(_called)
self.assertEqual(request._virtual_root, None)
def test___call___wo_SUPPRESS_ACCESSRULE(self):
_called = []
......
......@@ -166,16 +166,24 @@ class SiteRootTests(unittest.TestCase):
self.assertEqual(request, {})
def test___call___w_SUPPRESS_SITEROOT_in_URL(self):
# This behavior will change once we land lp:142878.
siteroot = self._makeOne(base='http://example.com', path='/path')
# This behavior changed in landing lp:142878.
URL='http://localhost:8080/example/folder/'
siteroot = self._makeOne(base='http://example.com', path='/example')
request = DummyRequest(TraversalRequestNameStack=
['_SUPPRESS_SITEROOT'])
def _dont_go_here(key, value):
raise NotImplementedError
request.__setitem__ = _dont_go_here
['_SUPPRESS_SITEROOT'],
URL=URL,
ACTUAL_URL=URL,
SERVER_URL='http://localhost:8080',
)
request.steps = []
request.environ = {}
siteroot(None, request)
self.assertEqual(request._virtual_root, ['_SUPPRESS_SITEROOT'])
self.assertEqual(request['URL'], URL)
self.assertEqual(request['SERVER_URL'], 'http://example.com')
self.assertEqual(request['ACTUAL_URL'],
'http://example.com/example/folder/')
self.assertEqual(request._virtual_root, '/example')
self.failUnless(request._urls_reset)
def test___call___wo_SUPPRESS_SITEROOT_w_base_wo_path(self):
URL='http://localhost:8080/example/folder/'
......
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