Mercurial > libervia-web
diff src/server/server.py @ 865:f024fc5744d0
server: fixes options parsing when url_redirections_dict or url_redirections_profile are not defined
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 22 Feb 2016 12:06:35 +0100 |
parents | e3e2effc9a4c |
children | 782ba105f5c7 |
line wrap: on
line diff
--- a/src/server/server.py Thu Feb 18 09:44:50 2016 +0100 +++ b/src/server/server.py Mon Feb 22 12:06:35 2016 +0100 @@ -121,10 +121,10 @@ ## redirections self.redirections = {} - if options['url_redirections_dict'] and not options['url_redirections_profile']: + if options.get('url_redirections_dict') is not None and not options['url_redirections_profile']: raise ValueError(u"url_redirections_profile need to be filled if you want to use url_redirections_dict") - for old, new in options['url_redirections_dict'].iteritems(): + for old, new in options.get('url_redirections_dict', {}).iteritems(): if not old.strip(): # root URL special case old = '' @@ -159,8 +159,8 @@ self.redirections[old] = request_data if not old: log.info(u"Root URL redirected to {uri}".format(uri=request_data[1].decode('utf-8'))) - del options['url_redirections_dict'] - del options['url_redirections_profile'] + options.pop('url_redirections_dict', None) + options.pop('url_redirections_profile', None) if not '' in self.redirections: self.redirections[''] = self._getRequestData(C.LIBERVIA_MAIN_PAGE)