diff libervia/server/pages.py @ 1145:29eb15062416

pages: set __name__ for imported pages
author Goffi <goffi@goffi.org>
date Fri, 25 Jan 2019 08:41:43 +0100
parents 2af117bfe6cc
children 76d75423ef53
line wrap: on
line diff
--- a/libervia/server/pages.py	Sat Jan 19 11:44:49 2019 +0100
+++ b/libervia/server/pages.py	Fri Jan 25 08:41:43 2019 +0100
@@ -28,7 +28,6 @@
 from sat.tools.common import date_utils
 from sat.core.log import getLogger
 
-log = getLogger(__name__)
 from libervia.server.constants import Const as C
 from libervia.server import session_iface
 from libervia.server.utils import quote, SubPage
@@ -40,6 +39,8 @@
 import time
 import hashlib
 
+log = getLogger(__name__)
+
 WebsocketMeta = namedtuple("WebsocketMeta", ("url", "token", "debug"))
 
 
@@ -280,12 +281,12 @@
             if not os.path.isdir(dir_path):
                 continue
             if _extra_pages and d in _parent.children:
-                log.debug(_(u"[{host_name}] {path} is already present, ignoring it").format(
-                    host_name=vhost_root.host_name, path=u'/'.join(_path+[d])))
+                log.debug(_(u"[{host_name}] {path} is already present, ignoring it")
+                    .format(host_name=vhost_root.host_name, path=u'/'.join(_path+[d])))
                 continue
             meta_path = os.path.join(dir_path, C.PAGES_META_FILE)
             if os.path.isfile(meta_path):
-                page_data = {}
+                page_data = {"__name__": u".".join([u"page"] + _path + [d])}
                 new_path = _path + [d]
                 # we don't want to force the presence of __init__.py
                 # so we use execfile instead of import.
@@ -1108,7 +1109,7 @@
 
         return self.host.renderer.render(
             self.template,
-            media_path="/" + C.MEDIA_DIR,
+            media_path=u"/" + C.MEDIA_DIR,
             cache_path=session_data.cache_dir,
             main_menu=self.main_menu,
             **template_data)