Mercurial > libervia-web
comparison libervia/server/server.py @ 1153:94f9d81a475e
pages: auto reloading
when developer mode is activated, pages are automatically reloaded when page_meta.py is modified.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 22 Feb 2019 16:57:37 +0100 |
parents | 1c23252958ed |
children | fb4b4da61132 |
comparison
equal
deleted
inserted
replaced
1152:1c23252958ed | 1153:94f9d81a475e |
---|---|
1876 if not u'' in self.options["menu_json"]: | 1876 if not u'' in self.options["menu_json"]: |
1877 self.options["menu_json"][u''] = C.DEFAULT_MENU | 1877 self.options["menu_json"][u''] = C.DEFAULT_MENU |
1878 | 1878 |
1879 # we create virtual hosts and import Libervia pages into them | 1879 # we create virtual hosts and import Libervia pages into them |
1880 self.vhost_root = vhost.NameVirtualHost() | 1880 self.vhost_root = vhost.NameVirtualHost() |
1881 default_site_path = os.path.dirname(libervia.__file__) | 1881 default_site_path = os.path.abspath(os.path.dirname(libervia.__file__)) |
1882 # self.sat_root is official Libervia site | 1882 # self.sat_root is official Libervia site |
1883 self.sat_root = default_root = LiberviaRootResource( | 1883 self.sat_root = default_root = LiberviaRootResource( |
1884 host=self, host_name=u'', site_name=u'', site_path=default_site_path, | 1884 host=self, host_name=u'', site_name=u'', site_path=default_site_path, |
1885 path=self.html_dir) | 1885 path=self.html_dir) |
1886 if self.options['dev_mode']: | |
1887 self.files_watcher.watchDir( | |
1888 default_site_path, auto_add=True, recursive=True, | |
1889 callback=LiberviaPage.onFileChange, site_root=self.sat_root, | |
1890 site_path=default_site_path) | |
1886 tasks_manager = TasksManager(self, self.sat_root) | 1891 tasks_manager = TasksManager(self, self.sat_root) |
1887 yield tasks_manager.runTasks() | 1892 yield tasks_manager.runTasks() |
1888 LiberviaPage.importPages(self, self.sat_root) | 1893 LiberviaPage.importPages(self, self.sat_root) |
1889 # FIXME: handle _setMenu in a more generic way, taking care of external sites | 1894 # FIXME: handle _setMenu in a more generic way, taking care of external sites |
1890 self.sat_root._setMenu(self.options["menu_json"]) | 1895 self.sat_root._setMenu(self.options["menu_json"]) |
1914 host=self, | 1919 host=self, |
1915 host_name=host_name, | 1920 host_name=host_name, |
1916 site_name=site_name, | 1921 site_name=site_name, |
1917 site_path=site_path, | 1922 site_path=site_path, |
1918 path=root_path) | 1923 path=root_path) |
1924 | |
1925 if self.options['dev_mode']: | |
1926 self.files_watcher.watchDir( | |
1927 site_path, auto_add=True, recursive=True, | |
1928 callback=LiberviaPage.onFileChange, site_root=res, | |
1929 site_path=site_path) | |
1919 tasks_manager = TasksManager(self, res) | 1930 tasks_manager = TasksManager(self, res) |
1920 yield tasks_manager.runTasks() | 1931 yield tasks_manager.runTasks() |
1921 res.putChild(C.BUILD_DIR, static.File(self.getBuildPath(site_name))) | 1932 res.putChild(C.BUILD_DIR, static.File(self.getBuildPath(site_name))) |
1922 self.vhost_root.addHost(host_name.encode('utf-8'), res) | 1933 self.vhost_root.addHost(host_name.encode('utf-8'), res) |
1923 LiberviaPage.importPages(self, res) | 1934 LiberviaPage.importPages(self, res) |