mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use a getter for link_maps in ProxyMetadata
Also allow is_null() to work with it.
This commit is contained in:
parent
aabd29c571
commit
6ddef11819
@ -391,7 +391,7 @@ class Cache:
|
||||
for key in composites:
|
||||
mi.set(key, val=self._composite_for(key, book_id, mi))
|
||||
|
||||
mi.link_maps = self.get_all_link_maps_for_book(book_id)
|
||||
mi.link_maps = self._get_all_link_maps_for_book(book_id)
|
||||
|
||||
user_cat_vals = {}
|
||||
if get_user_categories:
|
||||
|
@ -147,6 +147,15 @@ def adata_getter(field):
|
||||
return func
|
||||
|
||||
|
||||
def link_maps_getter(dbref, book_id, cache):
|
||||
try:
|
||||
ans = cache['link_maps']
|
||||
except KeyError:
|
||||
db = dbref()
|
||||
ans = cache['link_maps'] = db.get_all_link_maps_for_book(book_id)
|
||||
return ans
|
||||
|
||||
|
||||
def dt_getter(field):
|
||||
def func(dbref, book_id, cache):
|
||||
try:
|
||||
@ -300,6 +309,7 @@ getters = {
|
||||
'application_id':lambda x, book_id, y: book_id,
|
||||
'id':lambda x, book_id, y: book_id,
|
||||
'virtual_libraries':virtual_libraries_getter,
|
||||
'link_maps': link_maps_getter,
|
||||
}
|
||||
|
||||
for field in ('comments', 'publisher', 'identifiers', 'series', 'rating'):
|
||||
@ -351,10 +361,6 @@ class ProxyMetadata(Metadata):
|
||||
return custom_getter(field, ga(self, '_db'), ga(self, '_book_id'), ga(self, '_cache'))
|
||||
return composite_getter(self, field, ga(self, '_db'), ga(self, '_book_id'), ga(self, '_cache'), ga(self, 'formatter'), ga(self, 'template_cache'))
|
||||
|
||||
if field == 'link_maps':
|
||||
db = ga(self, '_db')()
|
||||
return db.get_all_link_maps_for_book(ga(self, '_book_id'))
|
||||
|
||||
try:
|
||||
return ga(self, '_cache')[field]
|
||||
except KeyError:
|
||||
|
@ -46,6 +46,7 @@ NULL_VALUES = {
|
||||
'title' : _('Unknown'),
|
||||
'user_categories' : {},
|
||||
'author_link_map' : {},
|
||||
'link_maps' : {},
|
||||
'language' : 'und'
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user