Przeglądaj źródła

backup sa_auth for all test running

Bastien Sevajol 9 lat temu
rodzic
commit
8ba70d75f4

+ 2 - 4
tracim/tracim/config/__init__.py Wyświetl plik

@@ -10,10 +10,8 @@ class TracimAppConfig(AppConfig):
10 10
     """
11 11
 
12 12
     def after_init_config(self, conf):
13
-        self._set_up_auth(conf)
13
+        AuthConfigWrapper.wrap(conf)
14 14
         #  Fix an tg2 strange thing: auth_backend is set in config, but instance
15 15
         #  of AppConfig has None in auth_backend attr
16 16
         self.auth_backend = conf['auth_backend']
17
-
18
-    def _set_up_auth(self, conf):
19
-        AuthConfigWrapper.wrap(conf)
17
+        self.sa_auth = conf.get('sa_auth')

+ 2 - 0
tracim/tracim/config/app_cfg.py Wyświetl plik

@@ -51,6 +51,8 @@ base_config.use_sqlalchemy = True
51 51
 base_config.model = tracim.model
52 52
 base_config.DBSession = tracim.model.DBSession
53 53
 
54
+# This value can be modified by tracim.lib.auth.wrapper.AuthConfigWrapper but have to be specified before
55
+base_config.auth_backend = 'sqlalchemy'
54 56
 
55 57
 # base_config.flash.cookie_name
56 58
 # base_config.flash.default_status -> Default message status if not specified (ok by default)

+ 21 - 0
tracim/tracim/lib/auth/base.py Wyświetl plik

@@ -1,4 +1,23 @@
1 1
 # -*- coding: utf-8 -*-
2
+from tg.util import Bunch
3
+
4
+_original_sa_auth = None
5
+
6
+
7
+def _get_clean_sa_auth(config):
8
+    """
9
+    TODO COMMENT
10
+    :param config:
11
+    :return:
12
+    """
13
+    global _original_sa_auth
14
+
15
+    if _original_sa_auth is None:
16
+        _original_sa_auth = dict(config.get('sa_auth'))
17
+
18
+    sa_auth = Bunch()
19
+    sa_auth.update(_original_sa_auth)
20
+    return sa_auth
2 21
 
3 22
 
4 23
 class Auth:
@@ -9,6 +28,8 @@ class Auth:
9 28
         self._config = config
10 29
 
11 30
     def wrap_config(self):
31
+        self._config['sa_auth'] = _get_clean_sa_auth(self._config)
32
+
12 33
         # override this if you would like to provide a different who plugin for
13 34
         # managing login and logout of your application
14 35
         self._config['sa_auth'].form_plugin = None