comparison libervia/server/server.py @ 1129:e6fe914c3eaf

server: move first level dict where the key has "/" to default site in _moveFirstLevelToDict
author Goffi <goffi@goffi.org>
date Sat, 15 Sep 2018 19:23:01 +0200
parents 6414fd795df4
children 8a7d75c18d40
comparison
equal deleted inserted replaced
1128:6414fd795df4 1129:e6fe914c3eaf
205 # some normalization 205 # some normalization
206 if not old.strip(): 206 if not old.strip():
207 # root URL special case 207 # root URL special case
208 old = "" 208 old = ""
209 elif not old.startswith("/"): 209 elif not old.startswith("/"):
210 log.error( 210 log.error(_(u"redirected url must start with '/', got {value}. Ignoring")
211 _( 211 .format(value=old))
212 u"redirected url must start with '/', got {value}. Ignoring"
213 ).format(value=old)
214 )
215 continue 212 continue
216 else: 213 else:
217 old = self._normalizeURL(old) 214 old = self._normalizeURL(old)
218 215
219 if isinstance(new, dict): 216 if isinstance(new, dict):
1769 options[key] = {u'': conf} 1766 options[key] = {u'': conf}
1770 return 1767 return
1771 default_dict = conf.setdefault(u'', {}) 1768 default_dict = conf.setdefault(u'', {})
1772 to_delete = [] 1769 to_delete = []
1773 for key, value in conf.iteritems(): 1770 for key, value in conf.iteritems():
1774 if not isinstance(value, dict): 1771 # "/" can't be present in host name, and help to differenciate from
1772 # non vhost dict (which may be used in redirections)
1773 if not isinstance(value, dict) or u'/' in key:
1775 default_dict[key] = value 1774 default_dict[key] = value
1776 to_delete.append(key) 1775 to_delete.append(key)
1777 for key in to_delete: 1776 for key in to_delete:
1778 del conf[key] 1777 del conf[key]
1779 1778