comparison src/server/server.py @ 866:782ba105f5c7

reverted changeset f024fc5744d0 (there is already a default value)
author Goffi <goffi@goffi.org>
date Wed, 24 Feb 2016 12:09:28 +0100
parents f024fc5744d0
children 12d0e7bd0dd1
comparison
equal deleted inserted replaced
865:f024fc5744d0 866:782ba105f5c7
119 """ 119 """
120 super(LiberviaRootResource, self).__init__(*args, **kwargs) 120 super(LiberviaRootResource, self).__init__(*args, **kwargs)
121 121
122 ## redirections 122 ## redirections
123 self.redirections = {} 123 self.redirections = {}
124 if options.get('url_redirections_dict') is not None and not options['url_redirections_profile']: 124 if options['url_redirections_dict'] and not options['url_redirections_profile']:
125 raise ValueError(u"url_redirections_profile need to be filled if you want to use url_redirections_dict") 125 raise ValueError(u"url_redirections_profile need to be filled if you want to use url_redirections_dict")
126 126
127 for old, new in options.get('url_redirections_dict', {}).iteritems(): 127 for old, new in options['url_redirections_dict'].iteritems():
128 if not old.strip(): 128 if not old.strip():
129 # root URL special case 129 # root URL special case
130 old = '' 130 old = ''
131 elif not old.startswith('/'): 131 elif not old.startswith('/'):
132 raise ValueError(u"redirected url must start with '/', got {}".format(old)) 132 raise ValueError(u"redirected url must start with '/', got {}".format(old))
157 else: 157 else:
158 raise NotImplementedError(u"{scheme}: scheme is not managed for url_redirections_dict".format(scheme=new_url.scheme)) 158 raise NotImplementedError(u"{scheme}: scheme is not managed for url_redirections_dict".format(scheme=new_url.scheme))
159 self.redirections[old] = request_data 159 self.redirections[old] = request_data
160 if not old: 160 if not old:
161 log.info(u"Root URL redirected to {uri}".format(uri=request_data[1].decode('utf-8'))) 161 log.info(u"Root URL redirected to {uri}".format(uri=request_data[1].decode('utf-8')))
162 options.pop('url_redirections_dict', None) 162 del options['url_redirections_dict']
163 options.pop('url_redirections_profile', None) 163 del options['url_redirections_profile']
164 164
165 if not '' in self.redirections: 165 if not '' in self.redirections:
166 self.redirections[''] = self._getRequestData(C.LIBERVIA_MAIN_PAGE) 166 self.redirections[''] = self._getRequestData(C.LIBERVIA_MAIN_PAGE)
167 167
168 def _normalizeURL(self, url, lower=True): 168 def _normalizeURL(self, url, lower=True):