瀏覽代碼

Closes #132: grep wsgidav config to set wbdav url

Bastien Sevajol (Algoo) 8 年之前
父節點
當前提交
ffbccc607b
共有 3 個文件被更改,包括 36 次插入3 次删除
  1. 4 0
      tracim/development.ini.base
  2. 30 1
      tracim/tracim/config/app_cfg.py
  3. 2 2
      tracim/tracim/controllers/workspace.py

+ 4 - 0
tracim/development.ini.base 查看文件

204
 
204
 
205
 ## WSGIDAV
205
 ## WSGIDAV
206
 wsgidav.config_path = wsgidav.conf
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 查看文件

12
     setting = asbool(global_conf.get('the_setting'))
12
     setting = asbool(global_conf.get('the_setting'))
13
  
13
  
14
 """
14
 """
15
+import imp
16
+import importlib
15
 from urllib.parse import urlparse
17
 from urllib.parse import urlparse
16
 
18
 
17
 import tg
19
 import tg
297
             '604800',
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
     def get_tracker_js_content(self, js_tracker_file_path = None):
331
     def get_tracker_js_content(self, js_tracker_file_path = None):
303
         js_tracker_file_path = tg.config.get('js_tracker_path', None)
332
         js_tracker_file_path = tg.config.get('js_tracker_path', None)

+ 2 - 2
tracim/tracim/controllers/workspace.py 查看文件

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