Anonymous avatar Anonymous committed f59488b

objectdb: using write_hook

Comments (0)

Files changed (4)


         self.persist = persist
         self.files = self
         self.compress = project.prefs.get('compress_objectdb', False)
-        if self.compress:
-            try:
-                import gzip
-                self.opener =
-            except ImportError:
-                self.compress = False
-        if not self.compress:
-            self.opener = open
-    def _get_persisted_file(self):
-        if self.compress:
-            return self.project.get_file(
-                self.project.ropefolder.path + '/objectdb.gz')
-        else:
-            return self.project.get_file(
-                self.project.ropefolder.path + '/objectdb')
+        self.project.data_files.add_write_hook(self.write)
     def _import_old_files(self):
-        persisted = self._get_persisted_file()
+        persisted = self.project.get_file( self.project.ropefolder.path + '/objectdb')
         old = self.project.get_file(self.project.ropefolder.path +
         if not persisted.exists() and old.exists() and not self.compress:
     def __delitem__(self, file):
         del self._files[file]
-    def sync(self):
+    def write(self):
         if self.persist:
             self.project.data_files.write_data('objectdb', self._files,


     def add_file_list_observer(self, observer):
-    def sync(self):
-        self.db.sync()
+    def write(self):
+        self.db.write()
     def _get_scope_info(self, path, key, readonly=True):
         if path not in self.files:


         return self.ignored.is_ignored(resource)
     def close(self):
-        self.pycore.object_info.sync()
+        self.data_files.write()
         super(Project, self).close()
     def set(self, key, value):


     def tearDown(self):
         for db in self.dbs:
-            db.sync()
+            db.write()
         super(ObjectDBTest, self).tearDown()
     def test_simple_per_name_after_syncing(self, db):
         db.add_pername('file', 'key', 'name', 1)
-        db.sync()
+        db.write()
         self.assertEquals(1, db.get_pername('file', 'key', 'name'))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.