Beispiel #1
0
    def __init__(self,
                 library_path,
                 default_prefs=None,
                 read_only=False,
                 is_second_db=False,
                 progress_callback=lambda x, y: True,
                 restore_all_prefs=False):

        self.is_second_db = is_second_db
        self.listeners = set()

        backend = self.backend = create_backend(
            library_path,
            default_prefs=default_prefs,
            read_only=read_only,
            restore_all_prefs=restore_all_prefs,
            progress_callback=progress_callback,
            load_user_formatter_functions=not is_second_db)
        cache = self.new_api = Cache(backend)
        cache.init()
        self.data = View(cache)
        self.id = self.data.index_to_id
        self.row = self.data.id_to_index
        for x in ('get_property', 'count', 'refresh_ids', 'set_marked_ids',
                  'multisort', 'search', 'search_getting_ids'):
            setattr(self, x, getattr(self.data, x))

        self.is_case_sensitive = getattr(backend, 'is_case_sensitive', False)
        self.custom_field_name = backend.custom_field_name

        self.last_update_check = self.last_modified()

        if not self.is_second_db:
            set_saved_searches(self, 'saved_searches')
Beispiel #2
0
    def __init__(self, library_path,
            default_prefs=None, read_only=False, is_second_db=False,
            progress_callback=lambda x, y:True, restore_all_prefs=False):

        self.is_second_db = is_second_db
        self.listeners = set()

        backend = self.backend = create_backend(library_path, default_prefs=default_prefs,
                    read_only=read_only, restore_all_prefs=restore_all_prefs,
                    progress_callback=progress_callback)
        cache = self.new_api = Cache(backend)
        cache.init()
        self.data = View(cache)
        self.id = self.data.index_to_id
        self.row = self.data.id_to_index
        for x in ('get_property', 'count', 'refresh_ids', 'set_marked_ids',
                  'multisort', 'search', 'search_getting_ids'):
            setattr(self, x, getattr(self.data, x))

        self.is_case_sensitive = getattr(backend, 'is_case_sensitive', False)
        self.custom_field_name = backend.custom_field_name

        self.last_update_check = self.last_modified()

        if not self.is_second_db:
            set_saved_searches(self, 'saved_searches')
Beispiel #3
0
def set_global_state(db):
    backend_set_global_state(db.backend)
    set_saved_searches(db, 'saved_searches')
Beispiel #4
0
def set_global_state(db):
    backend_set_global_state(db.backend)
    set_saved_searches(db, 'saved_searches')