Sfoglia il codice sorgente

Radicale config: separate host and prefix to correctly configure caldavzap

Bastien Sevajol (Algoo) 7 anni fa
parent
commit
975f936100

+ 3 - 1
tracim/development.ini.base Vedi File

@@ -209,7 +209,9 @@ email.processing_mode = sync
209 209
 # radicale.server.realm_message = Tracim Calendar - Password Required
210 210
 ## url can be extended like http://127.0.0.1:5232/calendar
211 211
 ## in this case, you have to create your own proxy behind this url.
212
-# radicale.client.base_url = http://127.0.0.1:5232
212
+## and update following parameters
213
+# radicale.client.base_url.host = http://127.0.0.1:5232
214
+# radicale.client.base_url.prefix = /
213 215
 
214 216
 ## WSGIDAV
215 217
 wsgidav.config_path = wsgidav.conf

+ 2 - 1
tracim/test.ini Vedi File

@@ -12,7 +12,8 @@ error_email_from = turbogears@localhost
12 12
 radicale.server.port = 15232
13 13
 radicale.client.port = 15232
14 14
 radicale.server.filesystem.folder = /tmp/tracim_tests_radicale_fs
15
-radicale.client.base_url = http://localhost:15232
15
+radicale.client.base_url.host = http://localhost:15232
16
+radicale.client.base_url.prefix = /
16 17
 email.notification.activated = false
17 18
 
18 19
 [server:main]

+ 18 - 12
tracim/tracim/config/app_cfg.py Vedi File

@@ -286,22 +286,28 @@ class CFG(object):
286 286
             'Tracim Calendar - Password Required',
287 287
         )
288 288
 
289
-        self.RADICALE_CLIENT_BASE_URL_TEMPLATE = \
290
-            tg.config.get('radicale.client.base_url', None)
289
+        self.RADICALE_CLIENT_BASE_URL_HOST = \
290
+            tg.config.get('radicale.client.base_url.host', None)
291 291
 
292
-        if not self.RADICALE_CLIENT_BASE_URL_TEMPLATE:
293
-            self.RADICALE_CLIENT_BASE_URL_TEMPLATE = \
294
-                'http://{0}:{1}'.format(
295
-                    self.WEBSITE_SERVER_NAME,
296
-                    self.RADICALE_SERVER_PORT,
297
-                )
292
+        self.RADICALE_CLIENT_BASE_URL_PREFIX = \
293
+            tg.config.get('radicale.client.base_url.prefix', '/')
294
+        # Ensure finished by '/'
295
+        if '/' != self.RADICALE_CLIENT_BASE_URL_PREFIX[-1]:
296
+            self.RADICALE_CLIENT_BASE_URL_PREFIX += '/'
297
+
298
+        if not self.RADICALE_CLIENT_BASE_URL_HOST:
298 299
             logger.warning(
299 300
                 self,
300
-                'NOTE: Generated radicale.client.base_url parameter with '
301
-                'followings parameters: website.server_name, '
302
-                'radicale.server.port -> {0}'
303
-                .format(self.RADICALE_CLIENT_BASE_URL_TEMPLATE)
301
+                'Generated radicale.client.base_url.host parameter with '
302
+                'followings parameters: website.server_name -> {}'
303
+                .format(self.RADICALE_CLIENT_BASE_URL_HOST)
304 304
             )
305
+            self.RADICALE_CLIENT_BASE_URL_HOST = self.RADICALE_SERVER_PORT
306
+
307
+        self.RADICALE_CLIENT_BASE_URL_TEMPLATE = '{}{}'.format(
308
+            self.RADICALE_CLIENT_BASE_URL_HOST,
309
+            self.RADICALE_CLIENT_BASE_URL_PREFIX,
310
+        )
305 311
 
306 312
         self.USER_AUTH_TOKEN_VALIDITY = int(tg.config.get(
307 313
             'user.auth_token.validity',

+ 4 - 1
tracim/tracim/controllers/calendar.py Vedi File

@@ -36,6 +36,9 @@ class CalendarConfigController(BaseController):
36 36
 
37 37
     @tg.expose('tracim.templates.calendar.config')
38 38
     def index(self):
39
+        from tracim.config.app_cfg import CFG
40
+        cfg = CFG.get_instance()
41
+
39 42
         # TODO BS 20160720: S'assurer d'être identifié !
40 43
         user = tmpl_context.identity.get('user')
41 44
         dictified_current_user = Context(CTX.CURRENT_USER).toDict(user)
@@ -48,7 +51,7 @@ class CalendarConfigController(BaseController):
48 51
         workspace_calendar_urls = CalendarManager\
49 52
             .get_workspace_readable_calendars_urls_for_user(user)
50 53
         base_href_url = \
51
-            re.sub(r"^http[s]?://", '', CalendarManager.get_base_url())
54
+            re.sub(r"^http[s]?://", '', cfg.RADICALE_CLIENT_BASE_URL_HOST)
52 55
 
53 56
         # Template will use User.auth_token, ensure it's validity
54 57
         user.ensure_auth_token()

+ 5 - 1
tracim/tracim/lib/daemons.py Vedi File

@@ -1,4 +1,3 @@
1
-import logging
2 1
 import threading
3 2
 from configparser import DuplicateSectionError
4 3
 from wsgiref.simple_server import make_server
@@ -231,6 +230,11 @@ class RadicaleDaemon(Daemon):
231 230
         radicale_config.set('storage', 'filesystem_folder', fs_path)
232 231
 
233 232
         radicale_config.set('server', 'realm', realm_message)
233
+        radicale_config.set(
234
+            'server',
235
+            'base_prefix',
236
+            cfg.RADICALE_CLIENT_BASE_URL_PREFIX,
237
+        )
234 238
 
235 239
         try:
236 240
             radicale_config.add_section('headers')