[migraction] do not access session.data directly
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 27 Jun 2013 11:19:32 +0200
changeset 9080 f0c00b07799a
parent 9079 f8c8e79218e1
child 9081 7c9a6dc4ee5d
[migraction] do not access session.data directly use set_shared_data and get_shared_data instead
hooks/syncschema.py
server/migractions.py
server/test/unittest_migractions.py
--- a/hooks/syncschema.py	Thu Jun 27 11:19:28 2013 +0200
+++ b/hooks/syncschema.py	Thu Jun 27 11:19:32 2013 +0200
@@ -211,7 +211,7 @@
                 clear_cache(eschema, 'ordered_relations')
 
     def postcommit_event(self):
-        rebuildinfered = self.session.data.get('rebuild-infered', True)
+        rebuildinfered = self.session.get_shared_data('rebuild-infered', True)
         repo = self.session.repo
         # commit event should not raise error, while set_schema has chances to
         # do so because it triggers full vreg reloading
--- a/server/migractions.py	Thu Jun 27 11:19:28 2013 +0200
+++ b/server/migractions.py	Thu Jun 27 11:19:32 2013 +0200
@@ -102,7 +102,7 @@
         # no config on shell to a remote instance
         if config is not None and (cnx or connect):
             repo = self.repo
-            self.session.data['rebuild-infered'] = False
+            self.session.set_shared_data('rebuild-infered', False)
             # register a hook to clear our group_mapping cache and the
             # self._synchronized set when some group is added or updated
             ClearGroupMap.mih = self
@@ -292,7 +292,7 @@
                     print 'aborting...'
                     sys.exit(0)
             self.session.keep_cnxset_mode('transaction')
-            self.session.data['rebuild-infered'] = False
+            self.session.set_shared_data('rebuild-infered', False)
             return self._cnx
 
     @property
--- a/server/test/unittest_migractions.py	Thu Jun 27 11:19:28 2013 +0200
+++ b/server/test/unittest_migractions.py	Thu Jun 27 11:19:32 2013 +0200
@@ -595,12 +595,12 @@
         #
         # also we need more tests about introducing/removing base classes or
         # specialization relationship...
-        self.session.data['rebuild-infered'] = True
+        self.session.set_shared_data('rebuild-infered', True)
         try:
             self.session.execute('DELETE X specializes Y WHERE Y name "Para"')
             self.session.commit(free_cnxset=False)
         finally:
-            self.session.data['rebuild-infered'] = False
+            self.session.set_shared_data('rebuild-infered', False)
         self.assertEqual(sorted(et.type for et in self.schema['Para'].specialized_by()),
                           [])
         self.assertEqual(self.schema['Note'].specializes(), None)