changeset 1199:b300eaec53b6

server: don't raise error anymore if themes_dir is invalid or legacy blog can't be created: legacy blog will be entirely removed with 0.8 release, and themes_dir is only used by it. This patch limit troubles with this old code by not raising an error anymore if option is wrong or if the legacy blog can't be created. fix 317
author Goffi <goffi@goffi.org>
date Tue, 09 Jul 2019 20:20:46 +0200
parents 1211dbc3cca7
children f9091f4e04f0
files libervia/server/server.py twisted/plugins/libervia_server.py
diffstat 2 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/server/server.py	Sat Jul 06 14:11:10 2019 +0200
+++ b/libervia/server/server.py	Tue Jul 09 20:20:46 2019 +0200
@@ -2026,8 +2026,15 @@
         self.putChildSAT("upload_avatar", _upload_avatar)
 
         # static pages
-        self.putChildSAT("blog_legacy", MicroBlog(self))
-        self.putChildSAT(C.THEMES_URL, ProtectedFile(self.themes_dir))
+        # FIXME: legacy blog must be removed entirely in 0.8
+        try:
+            micro_blog = MicroBlog(self)
+        except Exception as e:
+            log.warning(u"Can't load legacy microblog, ignoring it: {reason}".format(
+                reason=e))
+        else:
+            self.putChildSAT("blog_legacy", micro_blog)
+            self.putChildSAT(C.THEMES_URL, ProtectedFile(self.themes_dir))
 
         # websocket
         if self.options["connection_type"] in ("https", "both"):
--- a/twisted/plugins/libervia_server.py	Sat Jul 06 14:11:10 2019 +0200
+++ b/twisted/plugins/libervia_server.py	Tue Jul 09 20:20:46 2019 +0200
@@ -103,9 +103,11 @@
         )
     themes_dir = os.path.join(value, C.THEMES_DIR)
     if not os.path.isfile(os.path.join(themes_dir, "default/styles/blog.css")):
-        raise ValueError(
-            "%s is not a Libervia's server data directory" % os.path.realpath(themes_dir)
-        )
+        # XXX: we just display a message, as themes_dir is only used by legacy blog
+        #      which will be removed entirely in 0.8
+        # TODO: remove entirely legacy blog and linked options
+        print "%s is not a Libervia's server data directory" % os.path.realpath(
+            themes_dir)
     return value