Skip to content

Commit

Permalink
Fix VirtualHostMonster not being able to set mappings under Python 3. (
Browse files Browse the repository at this point in the history
…#709)

* Fix VirtualHostMonster not being able to set mappings under Python 3.
Fixes #708

* - Exception conversion lost in the merge

* - fix linting error
  • Loading branch information
thet authored and dataflake committed Oct 13, 2019
1 parent dbe4e50 commit ccdd919
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ https://github.com/zopefoundation/Zope/blob/4.x/CHANGES.rst
5.0a1 (unreleased)
------------------

- Fix VirtualHostMonster not being able to set mappings under Python 3.
(`#708 <https://github.com/zopefoundation/Zope/issues/708>`_)

- Reduce the danger of acquiring built-in names on the ZMI Find tab
(`#712 <https://github.com/zopefoundation/Zope/issues/712>`_)

Expand Down
4 changes: 2 additions & 2 deletions src/Products/SiteAccess/VirtualHostMonster.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def set_map(self, map_text, RESPONSE=None):
except Exception:
raise ValueError(
'Line needs a slash between host and path: %s' % line)
pp = filter(None, path.split('/'))
pp = list(filter(None, path.split('/')))
if pp:
obpath = pp[:]
if obpath[0] == 'VirtualHostBase':
Expand Down Expand Up @@ -104,7 +104,7 @@ def set_map(self, map_text, RESPONSE=None):
if hostname not in host_map:
host_map[hostname] = {}
host_map[hostname][port] = pp
except 'LineError' as msg:
except ValueError as msg:
line = '%s #! %s' % (line, msg)
new_lines.append(line)
self.lines = tuple(new_lines)
Expand Down
14 changes: 14 additions & 0 deletions src/Products/SiteAccess/tests/testVirtualHostMonster.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ def testWildcardRewrite(self):
'http://doc.example.com/')
self.assertEqual(ob.getPhysicalPath(), ('', 'folder', 'doc'))

def test_vhm_set_map(self):
vhm = self.app.virtual_hosting
mapping = """
somedomain1/folder
somedomain2/folder
""" # map with empty lines.
vhm.set_map(mapping)

self.assertEqual(len(vhm.lines), 2)
self.assertEqual(vhm.lines[0], 'somedomain1/folder')
self.assertEqual(vhm.lines[1], 'somedomain2/folder')


def gen_cases():
for vbase, ubase in (
Expand Down

0 comments on commit ccdd919

Please sign in to comment.