Browse Source

Closes #132: grep wsgidav config to set wbdav url

Bastien Sevajol (Algoo) 7 years ago
parent
commit
ffbccc607b

+ 4 - 0
tracim/development.ini.base View File

@@ -204,6 +204,10 @@ email.notification.smtp.password = your_smtp_password
204 204
 
205 205
 ## WSGIDAV
206 206
 wsgidav.config_path = wsgidav.conf
207
+## url can be extended like 127.0.0.1/webdav
208
+## in this case, you have to create your own proxy behind this url.
209
+## Do not set http:// prefix.
210
+# wsgidav.client.base_url = 127.0.0.1:<WSGIDAV_PORT>
207 211
 
208 212
 #####
209 213
 #

+ 30 - 1
tracim/tracim/config/app_cfg.py View File

@@ -12,6 +12,8 @@ convert them into boolean, for example, you should use the
12 12
     setting = asbool(global_conf.get('the_setting'))
13 13
  
14 14
 """
15
+import imp
16
+import importlib
15 17
 from urllib.parse import urlparse
16 18
 
17 19
 import tg
@@ -297,7 +299,34 @@ class CFG(object):
297 299
             '604800',
298 300
         ))
299 301
 
300
-        self.WSGIDAV_CONFIG_PATH = tg.config.get('wsgidav.config_path')
302
+        self.WSGIDAV_CONFIG_PATH = tg.config.get(
303
+            'wsgidav.config_path',
304
+            'wsgidav.conf',
305
+        )
306
+        # TODO: Convert to importlib (cf http://stackoverflow.com/questions/41063938/use-importlib-instead-imp-for-non-py-file)
307
+        self.wsgidav_config = imp.load_source(
308
+            'wsgidav_config',
309
+            self.WSGIDAV_CONFIG_PATH,
310
+        )
311
+        self.WSGIDAV_PORT = self.wsgidav_config.port
312
+        self.WSGIDAV_CLIENT_BASE_URL = \
313
+            tg.config.get('wsgidav.client.base_url', None)
314
+
315
+        if not self.WSGIDAV_CLIENT_BASE_URL:
316
+            self.WSGIDAV_CLIENT_BASE_URL = \
317
+                '{0}:{1}'.format(
318
+                    self.WEBSITE_SERVER_NAME,
319
+                    self.WSGIDAV_PORT,
320
+                )
321
+            logger.warning(
322
+                self,
323
+                'NOTE: Generated wsgidav.client.base_url parameter with '
324
+                'followings parameters: website.server_name and '
325
+                'wsgidav.conf port'.format(
326
+                    self.WSGIDAV_CLIENT_BASE_URL,
327
+                )
328
+            )
329
+
301 330
 
302 331
     def get_tracker_js_content(self, js_tracker_file_path = None):
303 332
         js_tracker_file_path = tg.config.get('js_tracker_path', None)

+ 2 - 2
tracim/tracim/controllers/workspace.py View File

@@ -65,14 +65,14 @@ class UserWorkspaceRestController(TIMRestController):
65 65
         )
66 66
 
67 67
         dictified_workspace = Context(CTX.WORKSPACE).toDict(workspace, 'workspace')
68
+        webdav_url = CFG.get_instance().WSGIDAV_CLIENT_BASE_URL
68 69
 
69 70
         return DictLikeClass(
70 71
             result=dictified_workspace,
71 72
             fake_api=fake_api,
72
-            webdav_url='@TODO-BASTIEN'
73
+            webdav_url=webdav_url,
73 74
         )
74 75
 
75
-
76 76
     @tg.expose('json')
77 77
     def treeview_root(self, id='#',
78 78
                       current_id=None,