comparison libervia/server/pages.py @ 1282:0e4e413eb8db

server: user new OrderedSet to handle scripts: OrderedSet is needed because scripts must not be duplicated and must be generated in right order.
author Goffi <goffi@goffi.org>
date Fri, 19 Jun 2020 16:47:51 +0200
parents 2e4fcd31f2a9
children 436ef2ad92af
comparison
equal deleted inserted replaced
1281:25eacbb1d59e 1282:0e4e413eb8db
127 LiberviaPages are the main resources of Libervia, using easy to set python files 127 LiberviaPages are the main resources of Libervia, using easy to set python files
128 The non mandatory arguments are the variables found in page_meta.py 128 The non mandatory arguments are the variables found in page_meta.py
129 @param host(Libervia): the running instance of Libervia 129 @param host(Libervia): the running instance of Libervia
130 @param vhost_root(web_resource.Resource): root resource of the virtual host which 130 @param vhost_root(web_resource.Resource): root resource of the virtual host which
131 handle this page. 131 handle this page.
132 @param root_dir(Path): aboslute file path of the page 132 @param root_dir(Path): absolute file path of the page
133 @param url(unicode): relative URL to the page 133 @param url(unicode): relative URL to the page
134 this URL may not be valid, as pages may require path arguments 134 this URL may not be valid, as pages may require path arguments
135 @param name(unicode, None): if not None, a unique name to identify the page 135 @param name(unicode, None): if not None, a unique name to identify the page
136 can then be used for e.g. redirection 136 can then be used for e.g. redirection
137 "/" is not allowed in names (as it can be used to construct URL paths) 137 "/" is not allowed in names (as it can be used to construct URL paths)
1340 try: 1340 try:
1341 scripts = data['scripts'] 1341 scripts = data['scripts']
1342 except KeyError: 1342 except KeyError:
1343 pass 1343 pass
1344 else: 1344 else:
1345 template_data.setdefault('scripts', set()).update(scripts) 1345 template_data.setdefault('scripts', utils.OrderedSet()).update(scripts)
1346 template_data.update(data.get('template', {})) 1346 template_data.update(data.get('template', {}))
1347 data_common = self.vhost_root.dyn_data_common 1347 data_common = self.vhost_root.dyn_data_common
1348 common_scripts = data_common['scripts'] 1348 common_scripts = data_common['scripts']
1349 if common_scripts: 1349 if common_scripts:
1350 template_data.setdefault('scripts', set()).update(common_scripts) 1350 template_data.setdefault('scripts', utils.OrderedSet()).update(common_scripts)
1351 if "template" in data_common: 1351 if "template" in data_common:
1352 for key, value in data_common["template"].items(): 1352 for key, value in data_common["template"].items():
1353 if key not in template_data: 1353 if key not in template_data:
1354 template_data[key] = value 1354 template_data[key] = value
1355 1355