Example #1
0
 def class_prepared_callback(self, sender, **kwargs):
     schema_dict = {}
     for field_name in self.fields:
         field = self.model._meta.get_field_by_name(field_name)[0]
         schema_dict[field.name] = field_mapping[field.__class__]
     self.schema = Schema(**schema_dict)
     if self.index is None:
         self.index = FileIndex.create(self.storage, self.schema)
     self.searcher = self.index.searcher()
     if self.real_time:
         post_save.connect(self.post_save_callback, sender=self.model)
         post_delete.connect(self.post_delete_callback, sender=self.model)
Example #2
0
 def class_prepared_callback(self, sender, **kwargs):
     schema_dict = {}
     for field_name in self.fields:
         field = self.model._meta.get_field_by_name(field_name)[0]
         schema_dict[field.name] = field_mapping[field.__class__]
     self.schema = Schema(**schema_dict)
     if self.index is None:
         self.index = FileIndex.create(self.storage, self.schema)
     self.searcher = self.index.searcher()
     if self.real_time:
         post_save.connect(self.post_save_callback, sender=self.model)
         post_delete.connect(self.post_delete_callback, sender=self.model)
Example #3
0
    def init_indexes(self):
        """Create indexes for schemas."""
        state = self.app_state

        for name, schema in self.schemas.items():
            if current_app.testing:
                storage = TestingStorage()
            else:
                index_path = (Path(state.whoosh_base) / name).absolute()
                if not index_path.exists():
                    index_path.mkdir(parents=True)
                storage = FileStorage(text_type(index_path))

            if storage.index_exists(name):
                index = FileIndex(storage, schema, name)
            else:
                index = FileIndex.create(storage, schema, name)

            state.indexes[name] = index
Example #4
0
    def init_indexes(self):
        """Create indexes for schemas."""
        state = self.app_state

        for name, schema in self.schemas.items():
            if current_app.testing:
                storage = TestingStorage()
            else:
                index_path = (Path(state.whoosh_base) / name).absolute()
                if not index_path.exists():
                    index_path.mkdir(parents=True)
                storage = FileStorage(str(index_path))

            if storage.index_exists(name):
                index = FileIndex(storage, schema, name)
            else:
                index = FileIndex.create(storage, schema, name)

            state.indexes[name] = index
Example #5
0
 def _create_index(self):
     storage = EncryptedFileStorage(self.index_folder, self.key)
     return FileIndex.create(storage, self._mail_schema(), indexname="mails")
Example #6
0
 def _create_index(self):
     masterkey = self.soledad_querier.get_index_masterkey
     storage = EncryptedFileStorage(self.INDEX_FOLDER, masterkey)
     return FileIndex.create(storage, self._mail_schema(), indexname='mails')
Example #7
0
 def _create_index(self):
     storage = EncryptedFileStorage(self.index_folder, self.key)
     return FileIndex.create(storage,
                             self._mail_schema(),
                             indexname='mails')
Example #8
0
 def _create_index(self):
     masterkey = self.soledad_querier.get_index_masterkey()
     storage = EncryptedFileStorage(self.INDEX_FOLDER, masterkey)
     return FileIndex.create(storage,
                             self._mail_schema(),
                             indexname='mails')