Mercurial > libervia-web
diff libervia/server/server.py @ 1127:9234f29053b0
server, pages: update to handle multi sites themes, first draft:
This first part of update handle changes in backend for multi-sites templates. Templates are now available in _t resource, followed by site name (default one is in "sat").
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 09 Sep 2018 21:12:22 +0200 |
parents | 7cd89277a129 |
children | 6414fd795df4 |
line wrap: on
line diff
--- a/libervia/server/server.py Fri Aug 31 18:08:06 2018 +0200 +++ b/libervia/server/server.py Sun Sep 09 21:12:22 2018 +0200 @@ -1644,6 +1644,11 @@ def _namespacesGetEb(self, failure_): log.error(_(u"Can't get namespaces map: {msg}").format(msg=failure_)) + def _front_url_filter(self, ctx, relative_url): + template_data = ctx[u'template_data'] + return os.path.join(u'/', C.TPL_RESOURCE, template_data.site or u'sat', + C.TEMPLATE_TPL_DIR, template_data.theme, relative_url) + def backendReady(self, dummy): self.root = root = LiberviaRootResource(self.html_dir) _register = Register(self) @@ -1768,8 +1773,11 @@ ) self.site = server.Site(wrapped) self.site.sessionFactory = LiberviaSession - self.renderer = template.Renderer(self) - self.putChild("templates", ProtectedFile(self.renderer.base_dir)) + self.renderer = template.Renderer(self, self._front_url_filter) + templates_res = web_resource.Resource() + self.putChild(C.TPL_RESOURCE, templates_res) + for site_name, site_path in self.renderer.sites_paths.iteritems(): + templates_res.putChild(site_name or u'sat', ProtectedFile(site_path)) def initEb(self, failure): log.error(_(u"Init error: {msg}").format(msg=failure))