diff libervia/server/pages.py @ 1224:62bf4f87c249

server: some encoding fixes following python 3 port
author Goffi <goffi@goffi.org>
date Sun, 06 Oct 2019 22:21:13 +0200
parents b2d067339de3
children 011147d7a931
line wrap: on
line diff
--- a/libervia/server/pages.py	Sun Aug 25 12:16:34 2019 +0200
+++ b/libervia/server/pages.py	Sun Oct 06 22:21:13 2019 +0200
@@ -1138,7 +1138,7 @@
                 redirect_page = redirect_page.original.children[subpage]
 
         if path_args is not None:
-            args = [quote(a) for a in path_args]
+            args = [quote(a).encode() for a in path_args]
             request.postpath = args + request.postpath
 
         if self._do_cache:
@@ -1277,7 +1277,7 @@
             log.warning("not allowed exception catched")
             self.pageError(request, C.HTTP_FORBIDDEN)
         log.error(_("Uncatched error for HTTP request on {url}: {msg}")
-            .format( url=request.URLPath(), msg=failure_))
+            .format(url=request.URLPath().decode(), msg=failure_))
         self.pageError(request, C.HTTP_INTERNAL_ERROR)
 
     def _on_data_post_error(self, failure_, request):
@@ -1561,9 +1561,10 @@
                 del request.postpath[-1]
 
             # i18n
-            if C.KEY_LANG in request.args:
+            key_lang = C.KEY_LANG.encode()
+            if key_lang in request.args:
                 try:
-                    locale = request.args.pop(C.KEY_LANG)[0]
+                    locale = request.args.pop(key_lang)[0].decode()
                 except IndexError:
                     log.warning("empty lang received")
                 else: