[web/config] refactor initialization of the data url
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 21 Feb 2012 16:58:43 +0100
changeset 8259 1c5be4a1afd1
parent 8258 88a7d2c49d39
child 8260 5a81fa526b30
[web/config] refactor initialization of the data url Common logic have been moved in a dedicated `data_relpath` function.
web/webconfig.py
--- a/web/webconfig.py	Thu Feb 23 11:58:16 2012 +0100
+++ b/web/webconfig.py	Tue Feb 21 16:58:43 2012 +0100
@@ -321,17 +321,20 @@
         if not (self.repairing or self.creating):
             self.global_set_option('base-url', baseurl)
         httpsurl = self['https-url']
-        if (self.debugmode or self.mode == 'test'):
-            datadir_path = 'data/'
-        else:
-            datadir_path = 'data/%s/' % self.instance_md5_version()
+        data_relpath = self.data_relpath()
         if httpsurl:
             if httpsurl[-1] != '/':
                 httpsurl += '/'
                 if not self.repairing:
                     self.global_set_option('https-url', httpsurl)
-            self.https_datadir_url = httpsurl + datadir_path
-        self.datadir_url = baseurl + datadir_path
+            self.https_datadir_url = httpsurl + data_relpath
+        self.datadir_url = baseurl + data_relpath
+
+    def data_relpath(self):
+        if (self.debugmode or self.mode == 'test'):
+            return 'data/'
+        else:
+            return 'data/%s/' % self.instance_md5_version()
 
     def _build_ui_properties(self):
         # self.datadir_url[:-1] to remove trailing /