Skip to content

Commit

Permalink
Merge 528f50d into 5962a30
Browse files Browse the repository at this point in the history
  • Loading branch information
thet committed Oct 3, 2019
2 parents 5962a30 + 528f50d commit 40b007c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ https://github.com/zopefoundation/Zope/blob/4.x/CHANGES.rst
5.0a1 (unreleased)
------------------

- Fix VirtualHostMonster not being able to set mappings under Python 3. Fixes #708
- Improve documentation for Zope's error logging services.

Backwards incompatible changes
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 Exception 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 40b007c

Please sign in to comment.