Browse Source

fix #52 sqlalchemy webdav issue

Guénaël Muller 6 years ago
parent
commit
f7ec425c59
3 changed files with 13 additions and 6 deletions
  1. 1 1
      tracim/lib/webdav/__init__.py
  2. 12 1
      tracim/models/__init__.py
  3. 0 4
      tracim/tests/library/test_webdav.py

+ 1 - 1
tracim/lib/webdav/__init__.py View File

@@ -75,9 +75,9 @@ class WebdavAppFactory(object):
75 75
             WsgiDavDirBrowser,
76 76
             TracimUserSession,
77 77
             HTTPAuthenticator,
78
-            TracimEnv,
79 78
             ErrorPrinter,
80 79
             TracimWsgiDavDebugFilter,
80
+            TracimEnv,
81 81
 
82 82
         ]
83 83
         config['provider_mapping'] = {

+ 12 - 1
tracim/models/__init__.py View File

@@ -48,8 +48,19 @@ def get_tm_session(session_factory, transaction_manager):
48 48
 
49 49
     """
50 50
     dbsession = session_factory()
51
+    # FIXME - G.M - 02-05-2018 - Check Zope/Sqlalchemy session conf.
52
+    # We use both keep_session=True for zope and
53
+    # expire_on_commit=False for sessionmaker to keep session alive after
54
+    # commit ( in order  to not have trouble like #52 or
55
+    # detached objects problems).
56
+    # These problem happened because we use "commit" in our current code.
57
+    # Understand what those params really mean and check if it can cause
58
+    # troubles somewhere else.
51 59
     zope.sqlalchemy.register(
52
-        dbsession, transaction_manager=transaction_manager)
60
+        dbsession,
61
+        transaction_manager=transaction_manager,
62
+        keep_session=True,
63
+    )
53 64
     listen(dbsession, 'before_flush', prevent_content_revision_delete)
54 65
     return dbsession
55 66
 

+ 0 - 4
tracim/tests/library/test_webdav.py View File

@@ -311,8 +311,6 @@ class TestWebDav(StandardTest):
311 311
             )
312 312
         )
313 313
 
314
-    @pytest.mark.xfail(raises=InvalidRequestError,
315
-                       reason='Sqlalchemy session and transaction bug')
316 314
     def test_unit__create_delete_and_create_file__ok(self):
317 315
         provider = self._get_provider(self.app_config)
318 316
         environ = self._get_environ(
@@ -559,8 +557,6 @@ class TestWebDav(StandardTest):
559 557
                 content_to_move.parent.label
560 558
         )
561 559
 
562
-    @pytest.mark.xfail(raises=InvalidRequestError,
563
-                       reason='Sqlalchemy session and transaction bug')
564 560
     def test_unit__update_content__ok(self):
565 561
         provider = self._get_provider(self.app_config)
566 562
         environ = self._get_environ(