[web] Add datadir-url configuration option (closes #5204550)
authorJulien Cristau <julien.cristau@logilab.fr>
Wed, 01 Apr 2015 15:50:59 +0200
changeset 10323 8cc58e8ad72f
parent 10322 d7c33cbdce8b
child 10324 6e44cc1d9c7e
[web] Add datadir-url configuration option (closes #5204550) Makes it possible to use a different host for static data instead of ${base_url}/data
web/webconfig.py
--- a/web/webconfig.py	Tue Mar 31 10:22:05 2015 +0200
+++ b/web/webconfig.py	Wed Apr 01 15:50:59 2015 +0200
@@ -124,6 +124,13 @@
           'where the cubicweb web server is listening on port 8080.',
           'group': 'main', 'level': 3,
           }),
+        ('datadir-url',
+         {'type': 'string', 'default': None,
+          'help': ('base url for static data, if different from "${base-url}/data/".  '
+                   'If served from a different domain, that domain should allow '
+                   'cross-origin requests.'),
+          'group': 'web',
+          }),
         ('auth-mode',
          {'type' : 'choice',
           'choices' : ('cookie', 'http'),
@@ -382,6 +389,14 @@
             baseurl += '/'
         if not (self.repairing or self.creating):
             self.global_set_option('base-url', baseurl)
+        self.datadir_url = self['datadir-url']
+        if self.datadir_url:
+            if self.datadir_url[-1] != '/':
+                self.datadir_url += '/'
+            if self.mode != 'test':
+                self.datadir_url += '%s/' % self.instance_md5_version()
+            self.https_datadir_url = self.datadir_url
+            return
         httpsurl = self['https-url']
         data_relpath = self.data_relpath()
         if httpsurl: