Commit 1688e10b authored by Tres Seaver's avatar Tres Seaver Committed by GitHub

Merge pull request #20 from navytux/y/zeo-ipv6

zeo: Fix parsing URI with IPv6 address
parents 71fb5f10 a3b501ce
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
- Add support for Python 3.6. - Add support for Python 3.6.
- Fix parsing of ``zeo://`` URI with IPv6 address.
2.2.2 (2017-05-05) 2.2.2 (2017-05-05)
------------------ ------------------
......
...@@ -102,3 +102,4 @@ Contributors ...@@ -102,3 +102,4 @@ Contributors
- Steve Piercy, 2016/07/21 - Steve Piercy, 2016/07/21
- Todd Koym, 2016/07/21 - Todd Koym, 2016/07/21
- Jim Fulton, 2017/04/13 - Jim Fulton, 2017/04/13
- Kirill Smelkov, 2017/10/17
...@@ -134,21 +134,19 @@ class ClientStorageURIResolver(Resolver): ...@@ -134,21 +134,19 @@ class ClientStorageURIResolver(Resolver):
# urlsplit doesnt understand zeo URLs so force to something that # urlsplit doesnt understand zeo URLs so force to something that
# doesn't break # doesn't break
uri = uri.replace('zeo://', 'http://', 1) uri = uri.replace('zeo://', 'http://', 1)
(scheme, netloc, path, query, frag) = urlsplit(uri) u = urlsplit(uri)
if netloc: if u.netloc:
# TCP URL # TCP URL
if ':' in netloc: host = u.hostname
host, port = netloc.split(':') port = u.port
port = int(port) if port is None:
else:
host = netloc
port = 9991 port = 9991
args = ((host, port),) args = ((host, port),)
else: else:
# Unix domain socket URL # Unix domain socket URL
path = os.path.normpath(path) path = os.path.normpath(u.path)
args = (path,) args = (path,)
kw = dict(parse_qsl(query)) kw = dict(parse_qsl(u.query))
kw, unused = self.interpret_kwargs(kw) kw, unused = self.interpret_kwargs(kw)
if 'demostorage' in kw: if 'demostorage' in kw:
kw.pop('demostorage') kw.pop('demostorage')
......
...@@ -252,6 +252,20 @@ class TestClientStorageURIResolver(unittest.TestCase): ...@@ -252,6 +252,20 @@ class TestClientStorageURIResolver(unittest.TestCase):
factory() factory()
ClientStorage.assert_called_once_with(('localhost', 8080), debug=1) ClientStorage.assert_called_once_with(('localhost', 8080), debug=1)
@mock.patch('zodburi.resolvers.ClientStorage')
def test_call_ipv6_no_port(self, ClientStorage):
resolver = self._makeOne()
factory, dbkw = resolver('zeo://[::1]?debug=true')
factory()
ClientStorage.assert_called_once_with(('::1', 9991), debug=1)
@mock.patch('zodburi.resolvers.ClientStorage')
def test_call_ipv6(self, ClientStorage):
resolver = self._makeOne()
factory, dbkw = resolver('zeo://[::1]:9090?debug=true')
factory()
ClientStorage.assert_called_once_with(('::1', 9090), debug=1)
@mock.patch('zodburi.resolvers.ClientStorage') @mock.patch('zodburi.resolvers.ClientStorage')
def test_call_unix(self, ClientStorage): def test_call_unix(self, ClientStorage):
resolver = self._makeOne() resolver = self._makeOne()
......
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