comparison libervia/server/server.py @ 1253:6d49fae517ba

pages: browser metadata + root `_browser`: - the `_browser` directory can now be put in root of a site `pages` directory, it will then include modules for the whole website - in `_browser` directories (notably the root one), a `browser_meta.json` file can be put to specify settings for a browser engine - pathlib.Path is now used LiberviaRootResource.site_path - introduced some type hints - task_brython copy modules in root `_browser` to build_path root. - minimal python version is now 3.7 due to type hints
author Goffi <goffi@goffi.org>
date Wed, 29 Apr 2020 17:34:53 +0200
parents a1606e2a92eb
children 08cd652dea14
comparison
equal deleted inserted replaced
1252:80a92eb82b7f 1253:6d49fae517ba
181 def __init__(self, host, host_name, site_name, site_path, *args, **kwargs): 181 def __init__(self, host, host_name, site_name, site_path, *args, **kwargs):
182 ProtectedFile.__init__(self, *args, **kwargs) 182 ProtectedFile.__init__(self, *args, **kwargs)
183 self.host = host 183 self.host = host
184 self.host_name = host_name 184 self.host_name = host_name
185 self.site_name = site_name 185 self.site_name = site_name
186 self.site_path = site_path 186 self.site_path = Path(site_path)
187 self.named_pages = {} 187 self.named_pages = {}
188 self.browser_modules = {} 188 self.browser_modules = {}
189 self.uri_callbacks = {} 189 self.uri_callbacks = {}
190 self.pages_redirects = {} 190 self.pages_redirects = {}
191 self.cached_urls = {} 191 self.cached_urls = {}
784 if not '' in self.options["menu_json"]: 784 if not '' in self.options["menu_json"]:
785 self.options["menu_json"][''] = C.DEFAULT_MENU 785 self.options["menu_json"][''] = C.DEFAULT_MENU
786 786
787 # we create virtual hosts and import Libervia pages into them 787 # we create virtual hosts and import Libervia pages into them
788 self.vhost_root = vhost.NameVirtualHost() 788 self.vhost_root = vhost.NameVirtualHost()
789 default_site_path = os.path.abspath(os.path.dirname(libervia.__file__)) 789 default_site_path = Path(libervia.__file__).parent.resolve()
790 # self.sat_root is official Libervia site 790 # self.sat_root is official Libervia site
791 root_path = os.path.join(default_site_path, C.TEMPLATE_STATIC_DIR) 791 root_path = default_site_path / C.TEMPLATE_STATIC_DIR
792 self.sat_root = default_root = LiberviaRootResource( 792 self.sat_root = default_root = LiberviaRootResource(
793 host=self, host_name='', site_name='', 793 host=self, host_name='', site_name='',
794 site_path=default_site_path, path=root_path) 794 site_path=default_site_path, path=root_path)
795 if self.options['dev_mode']: 795 if self.options['dev_mode']:
796 self.files_watcher.watchDir( 796 self.files_watcher.watchDir(