Mercurial > libervia-web
comparison libervia/server/pages.py @ 1268:e628724530ec
pages, tasks (brython): use set for scripts + common template data:
- scripts are put in a set using a namedtuple, this way duplicates can be avoided easily
- if `template` is set in dyn_data_common, items there are set in template data if they
don't already exist
- (brython): common template data is used to set body_onload when there is a root brython
script and no page script
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 19 May 2020 11:05:40 +0200 |
parents | b5f920845d34 |
children | 6dfcdbeb0d33 |
comparison
equal
deleted
inserted
replaced
1267:b5f920845d34 | 1268:e628724530ec |
---|---|
1330 try: | 1330 try: |
1331 scripts = data['scripts'] | 1331 scripts = data['scripts'] |
1332 except KeyError: | 1332 except KeyError: |
1333 pass | 1333 pass |
1334 else: | 1334 else: |
1335 template_data.setdefault('scripts', []).extend(scripts) | 1335 template_data.setdefault('scripts', set()).update(scripts) |
1336 template_data.update(data.get('template', {})) | 1336 template_data.update(data.get('template', {})) |
1337 common_scripts = self.vhost_root.dyn_data_common['scripts'] | 1337 data_common = self.vhost_root.dyn_data_common |
1338 common_scripts = data_common['scripts'] | |
1338 if common_scripts: | 1339 if common_scripts: |
1339 template_data.setdefault('scripts', []).extend(common_scripts) | 1340 template_data.setdefault('scripts', set()).update(common_scripts) |
1341 if "template" in data_common: | |
1342 for key, value in data_common["template"].items(): | |
1343 if key not in template_data: | |
1344 template_data[key] = value | |
1340 | 1345 |
1341 return self.host.renderer.render( | 1346 return self.host.renderer.render( |
1342 self.template, | 1347 self.template, |
1343 site_themes=self.vhost_root.site_themes, | 1348 site_themes=self.vhost_root.site_themes, |
1344 page_url=self.getURL(), | 1349 page_url=self.getURL(), |