mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-16 03:05:32 +01:00
Add get/set of namespaced prefs to new DB API
This commit is contained in:
parent
9ec29bb548
commit
f4e1d5cc01
1 changed files with 7 additions and 2 deletions
|
|
@ -623,13 +623,18 @@ def format_files(self, book_id):
|
|||
return {fmt:field.format_fname(book_id, fmt) for fmt in fmts}
|
||||
|
||||
@read_api
|
||||
def pref(self, name, default=None):
|
||||
def pref(self, name, default=None, namespace=None):
|
||||
' Return the value for the specified preference or the value specified as ``default`` if the preference is not set. '
|
||||
if namespace is not None:
|
||||
return self.backend.prefs.get_namespaced(namespace, name, default)
|
||||
return self.backend.prefs.get(name, default)
|
||||
|
||||
@write_api
|
||||
def set_pref(self, name, val):
|
||||
def set_pref(self, name, val, namespace=None):
|
||||
' Set the specified preference to the specified value. See also :meth:`pref`. '
|
||||
if namespace is not None:
|
||||
self.backend.prefs.set_namespaced(namespace, name, val)
|
||||
return
|
||||
self.backend.prefs.set(name, val)
|
||||
if name == 'grouped_search_terms':
|
||||
self._clear_search_caches()
|
||||
|
|
|
|||
Loading…
Reference in a new issue