comparison libervia/server/pages.py @ 1324:898442c4ff68

pages: expose `cache_path` to scripts + `session_uuid` to templates
author Goffi <goffi@goffi.org>
date Fri, 14 Aug 2020 09:06:56 +0200
parents a0954b6610aa
children 9bfd2d0661b2
comparison
equal deleted inserted replaced
1323:a20fe9eb307b 1324:898442c4ff68
1424 template_data[key] = value 1424 template_data[key] = value
1425 1425
1426 theme = session_data.theme or self.default_theme 1426 theme = session_data.theme or self.default_theme
1427 self.exposeToScripts( 1427 self.exposeToScripts(
1428 request, 1428 request,
1429 cache_path=session_data.cache_dir,
1429 templates_root_url=str(self.vhost_root.getFrontURL(theme)), 1430 templates_root_url=str(self.vhost_root.getFrontURL(theme)),
1430 profile=session_data.profile) 1431 profile=session_data.profile)
1431 1432
1432 return self.host.renderer.render( 1433 return self.host.renderer.render(
1433 self.template, 1434 self.template,
1693 # template_data are the variables passed to template 1694 # template_data are the variables passed to template
1694 if not hasattr(request, "template_data"): 1695 if not hasattr(request, "template_data"):
1695 # if template_data doesn't exist, it's the beginning of the request workflow 1696 # if template_data doesn't exist, it's the beginning of the request workflow
1696 # so we fill essential data 1697 # so we fill essential data
1697 session_data = self.host.getSessionData(request, session_iface.ISATSession) 1698 session_data = self.host.getSessionData(request, session_iface.ISATSession)
1698 csrf_token = session_data.csrf_token
1699 request.template_data = { 1699 request.template_data = {
1700 "profile": session_data.profile, 1700 "profile": session_data.profile,
1701 "csrf_token": csrf_token, 1701 "csrf_token": session_data.csrf_token,
1702 "session_uuid": session_data.uuid,
1702 } 1703 }
1703 1704
1704 # XXX: here is the code which need to be executed once 1705 # XXX: here is the code which need to be executed once
1705 # at the beginning of the request hanling 1706 # at the beginning of the request hanling
1706 if request.postpath and not request.postpath[-1]: 1707 if request.postpath and not request.postpath[-1]: