Browse Source

Radicale config: separate host and prefix to correctly configure caldavzap

Bastien Sevajol (Algoo) 8 years ago
parent
commit
975f936100

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

209
 # radicale.server.realm_message = Tracim Calendar - Password Required
209
 # radicale.server.realm_message = Tracim Calendar - Password Required
210
 ## url can be extended like http://127.0.0.1:5232/calendar
210
 ## url can be extended like http://127.0.0.1:5232/calendar
211
 ## in this case, you have to create your own proxy behind this url.
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
 ## WSGIDAV
216
 ## WSGIDAV
215
 wsgidav.config_path = wsgidav.conf
217
 wsgidav.config_path = wsgidav.conf

+ 2 - 1
tracim/test.ini View File

12
 radicale.server.port = 15232
12
 radicale.server.port = 15232
13
 radicale.client.port = 15232
13
 radicale.client.port = 15232
14
 radicale.server.filesystem.folder = /tmp/tracim_tests_radicale_fs
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
 email.notification.activated = false
17
 email.notification.activated = false
17
 
18
 
18
 [server:main]
19
 [server:main]

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

286
             'Tracim Calendar - Password Required',
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
             logger.warning(
299
             logger.warning(
299
                 self,
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
         self.USER_AUTH_TOKEN_VALIDITY = int(tg.config.get(
312
         self.USER_AUTH_TOKEN_VALIDITY = int(tg.config.get(
307
             'user.auth_token.validity',
313
             'user.auth_token.validity',

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

36
 
36
 
37
     @tg.expose('tracim.templates.calendar.config')
37
     @tg.expose('tracim.templates.calendar.config')
38
     def index(self):
38
     def index(self):
39
+        from tracim.config.app_cfg import CFG
40
+        cfg = CFG.get_instance()
41
+
39
         # TODO BS 20160720: S'assurer d'être identifié !
42
         # TODO BS 20160720: S'assurer d'être identifié !
40
         user = tmpl_context.identity.get('user')
43
         user = tmpl_context.identity.get('user')
41
         dictified_current_user = Context(CTX.CURRENT_USER).toDict(user)
44
         dictified_current_user = Context(CTX.CURRENT_USER).toDict(user)
48
         workspace_calendar_urls = CalendarManager\
51
         workspace_calendar_urls = CalendarManager\
49
             .get_workspace_readable_calendars_urls_for_user(user)
52
             .get_workspace_readable_calendars_urls_for_user(user)
50
         base_href_url = \
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
         # Template will use User.auth_token, ensure it's validity
56
         # Template will use User.auth_token, ensure it's validity
54
         user.ensure_auth_token()
57
         user.ensure_auth_token()

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

1
-import logging
2
 import threading
1
 import threading
3
 from configparser import DuplicateSectionError
2
 from configparser import DuplicateSectionError
4
 from wsgiref.simple_server import make_server
3
 from wsgiref.simple_server import make_server
231
         radicale_config.set('storage', 'filesystem_folder', fs_path)
230
         radicale_config.set('storage', 'filesystem_folder', fs_path)
232
 
231
 
233
         radicale_config.set('server', 'realm', realm_message)
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
         try:
239
         try:
236
             radicale_config.add_section('headers')
240
             radicale_config.add_section('headers')