Commits

Anonymous committed 0854bf3

oi: dynamically loading project options

  • Participants
  • Parent commits 9081897

Comments (0)

Files changed (2)

rope/base/oi/memorydb.py

 
 class MemoryDB(objectdb.FileDict):
 
-    def __init__(self, project, persist=False):
+    def __init__(self, project, persist=None):
         self.project = project
-        self.persist = persist
+        self._persist = persist
         self.files = self
-        self.compress = project.prefs.get('compress_objectdb', False)
         self._load_files()
         self.project.data_files.add_write_hook(self.write)
 
             self.project.data_files.write_data('objectdb', self._files,
                                                self.compress)
 
+    @property
+    def compress(self):
+        return self.project.prefs.get('compress_objectdb', False)
+
+    @property
+    def persist(self):
+        if self._persist is not None:
+            return self._persist
+        else:
+            return self.project.prefs.get('save_objectdb', False)
+
 
 class FileInfo(objectdb.FileInfo):
 

rope/base/oi/objectinfo.py

         self.to_pyobject = transform.TextualToPyObject(project)
         self.doi_to_pyobject = transform.DOITextualToPyObject(project)
         self._init_objectdb()
-        if project.get_prefs().get('validate_objectdb', False):
+        if project.prefs.get('validate_objectdb', False):
             self._init_validation()
 
     def _init_objectdb(self):
         dbtype = self.project.get_prefs().get('objectdb_type', None)
+        persist = None
         if dbtype is not None:
             warnings.warn(
                 '"objectdb_type" project config is deprecated;\n'
                 'Use "save_objectdb" instead in your project '
                 'config file.\n(".ropeproject/config.py" by default)\n',
                 DeprecationWarning)
-            save = dbtype != 'memory'
-        else:
-            save = self.project.get_prefs().get('save_objectdb', False)
+            if dbtype != 'memory' and self.project.ropefolder is not None:
+                persist = True
         self.validation = TextualValidation(self.to_pyobject)
-        if save and self.project.ropefolder is not None:
-            db = memorydb.MemoryDB(self.project, persist=True)
-        else:
-            db = memorydb.MemoryDB(self.project, persist=False)
+        db = memorydb.MemoryDB(self.project, persist=persist)
         self.objectdb = objectdb.ObjectDB(db, self.validation)
 
     def _init_validation(self):