[MapProxy] French IGN WMTS configuration in MapProxy

Oliver Tonnhofer olt at omniscale.de
Wed Jan 16 04:47:01 PST 2013


On 16.01.2013, at 11:33, Antoine JAMMES wrote:
> I guess the problem come from the login that is an email (ie with an @)
> So I have change the method auth_data_from_url(url) of
> mapproxy/lib/python2.7/site-packages/mapproxy/client/http.py
> 
> replacing :
> [...]
>            auth_data, host = host.split('@', 2)

Yes, this line is wrong. It needs to split at maximum 1 time, not 2 and the split needs to start from right (so .rsplit, instead of .split).

I fixed it https://github.com/mapproxy/mapproxy/commit/e9d7816ba9ae30a18307c610d53b903a318abac4?w=1


> def auth_data_from_url(url):
>    """
>>>> auth_data_from_url('http://localhost/bar')
>    ('http://localhost/bar', (None, None))
>>>> auth_data_from_url('http://bar@localhost/bar')
>    ('http://localhost/bar', ('bar', None))
>>>> auth_data_from_url('http://bar:baz@localhost/bar')
>    ('http://localhost/bar', ('bar', 'baz'))
>    """
>    username = password = None
>    if '@' in url:
>        scheme, host, path, query, frag = urlsplit(url)
>        if '@' in host:
>            sep = host.rfind("@")
>            auth_data = host[:sep]
>            host = host[sep +1:]
>            if ':' in auth_data:
>                username, password = auth_data.split(':', 2)
>            else:
>                username = auth_data
>    return url, (username, password)

You accidentally removed the `url = ...` line.


Regards,
Oliver

-- 
Oliver Tonnhofer    | Omniscale GmbH & Co KG    | http://omniscale.de
http://mapproxy.org | https://github.com/olt    | @oltonn








More information about the MapProxy mailing list