Commit 3caa940b authored by Tres Seaver's avatar Tres Seaver

Remove some insanity, now that we have coverage.

parent 4a6b35ad
...@@ -87,20 +87,6 @@ class SiteRoot(Traverser, Implicit): ...@@ -87,20 +87,6 @@ class SiteRoot(Traverser, Implicit):
self.title = title.strip() self.title = title.strip()
self.base = base = base.strip() self.base = base = base.strip()
self.path = path = path.strip() self.path = path = path.strip()
if base:
self.SiteRootBASE = base
else:
try:
del self.SiteRootBASE
except:
pass
if path:
self.SiteRootPATH = path
else:
try:
del self.SiteRootPATH
except:
pass
def manage_edit(self, title, base, path, REQUEST=None): def manage_edit(self, title, base, path, REQUEST=None):
""" Set the title, base, and path. """ Set the title, base, and path.
...@@ -114,30 +100,26 @@ class SiteRoot(Traverser, Implicit): ...@@ -114,30 +100,26 @@ class SiteRoot(Traverser, Implicit):
def __call__(self, client, request, response=None): def __call__(self, client, request, response=None):
""" Traversing. """ Traversing.
""" """
rq = request
if SUPPRESS_SITEROOT: if SUPPRESS_SITEROOT:
return return
if '_SUPPRESS_SITEROOT' in _swallow(request, '_SUPPRESS'): if '_SUPPRESS_SITEROOT' in _swallow(rq, '_SUPPRESS'):
request.setVirtualRoot(request.steps) rq.setVirtualRoot(rq.steps)
return return
srd = [None, None] base = (self.base or
for i in (0, 1): rq.get('SiteRootBASE') or
srp = ('SiteRootBASE', 'SiteRootPATH')[i] rq.environ.get('SiteRootBASE'))
try: path = (self.path or
srd[i] = getattr(self, srp) rq.get('SiteRootPATH') or
except AttributeError: rq.environ.get('SiteRootPATH'))
srd[i] = request.get(srp, None) if base is not None:
if srd[i] is None: rq['ACTUAL_URL'] = rq['ACTUAL_URL'].replace(rq['SERVER_URL'], base)
srd[i] = request.environ.get(srp, None) rq['SERVER_URL'] = base
if srd[0] is not None: rq._resetURLS()
request['ACTUAL_URL'] = request['ACTUAL_URL'].replace( if path is not None:
request['SERVER_URL'], srd[0]) old = rq['URL']
request['SERVER_URL'] = srd[0] rq.setVirtualRoot(path)
request._resetURLS() rq['ACTUAL_URL'] = rq['ACTUAL_URL'].replace(old, rq['URL'])
if srd[1] is not None:
old = request['URL']
request.setVirtualRoot(srd[1])
request['ACTUAL_URL'] = request['ACTUAL_URL'].replace(
old, request['URL'])
def get_size(self): def get_size(self):
""" Make FTP happy """ Make FTP happy
......
...@@ -127,18 +127,12 @@ class SiteRootTests(unittest.TestCase): ...@@ -127,18 +127,12 @@ class SiteRootTests(unittest.TestCase):
self.assertEqual(siteroot.title, 'TITLE') self.assertEqual(siteroot.title, 'TITLE')
self.assertEqual(siteroot.base, '') self.assertEqual(siteroot.base, '')
self.assertEqual(siteroot.path, '') self.assertEqual(siteroot.path, '')
# XXX Why aren't these defaulted to None at class scope?
# Even better: why do they exist at all?
self.failUnless(getattr(siteroot, 'SiteRootBase', self) is self)
self.failUnless(getattr(siteroot, 'SiteRootPath', self) is self)
def test___init___w_base_and_path(self): def test___init___w_base_and_path(self):
siteroot = self._makeOne(base='http://example.com', path='/path') siteroot = self._makeOne(base='http://example.com', path='/path')
self.assertEqual(siteroot.title, 'TITLE') self.assertEqual(siteroot.title, 'TITLE')
self.assertEqual(siteroot.base, 'http://example.com') self.assertEqual(siteroot.base, 'http://example.com')
self.assertEqual(siteroot.path, '/path') self.assertEqual(siteroot.path, '/path')
self.assertEqual(siteroot.SiteRootBASE, 'http://example.com')
self.assertEqual(siteroot.SiteRootPATH, '/path')
def test_manage_edit_no_REQUEST(self): def test_manage_edit_no_REQUEST(self):
siteroot = self._makeOne(title='Before', siteroot = self._makeOne(title='Before',
...@@ -150,8 +144,6 @@ class SiteRootTests(unittest.TestCase): ...@@ -150,8 +144,6 @@ class SiteRootTests(unittest.TestCase):
self.assertEqual(siteroot.title, 'After') self.assertEqual(siteroot.title, 'After')
self.assertEqual(siteroot.base, 'http://after.example.com') self.assertEqual(siteroot.base, 'http://after.example.com')
self.assertEqual(siteroot.path, '/after') self.assertEqual(siteroot.path, '/after')
self.assertEqual(siteroot.SiteRootBASE, 'http://after.example.com')
self.assertEqual(siteroot.SiteRootPATH, '/after')
def test_manage_edit_w_REQUEST(self): def test_manage_edit_w_REQUEST(self):
siteroot = self._makeOne(title='Before', siteroot = self._makeOne(title='Before',
...@@ -165,8 +157,6 @@ class SiteRootTests(unittest.TestCase): ...@@ -165,8 +157,6 @@ class SiteRootTests(unittest.TestCase):
self.assertEqual(siteroot.title, 'After') self.assertEqual(siteroot.title, 'After')
self.assertEqual(siteroot.base, 'http://after.example.com') self.assertEqual(siteroot.base, 'http://after.example.com')
self.assertEqual(siteroot.path, '/after') self.assertEqual(siteroot.path, '/after')
self.assertEqual(siteroot.SiteRootBASE, 'http://after.example.com')
self.assertEqual(siteroot.SiteRootPATH, '/after')
def test___call___w_SUPPRESS_SITEROOT_set(self): def test___call___w_SUPPRESS_SITEROOT_set(self):
self._set_SUPPRESS_SITEROOT(1) self._set_SUPPRESS_SITEROOT(1)
......
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