mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix handling of recursive templates in ProxyMetadata
This commit is contained in:
parent
d0b1001ee7
commit
415dc21588
@ -12,7 +12,7 @@ from functools import wraps
|
||||
from collections import MutableMapping, MutableSequence
|
||||
from copy import deepcopy
|
||||
|
||||
from calibre.ebooks.metadata.book.base import Metadata, SIMPLE_GET, TOP_LEVEL_IDENTIFIERS, NULL_VALUES
|
||||
from calibre.ebooks.metadata.book.base import Metadata, SIMPLE_GET, TOP_LEVEL_IDENTIFIERS, NULL_VALUES, ALL_METADATA_FIELDS
|
||||
from calibre.ebooks.metadata.book.formatter import SafeFormat
|
||||
from calibre.utils.date import utcnow
|
||||
|
||||
@ -350,3 +350,8 @@ class ProxyMetadata(Metadata):
|
||||
return field_metadata[field]
|
||||
return None
|
||||
|
||||
def all_field_keys(self):
|
||||
um = ga(self, '_user_metadata')
|
||||
return frozenset(ALL_METADATA_FIELDS.union(um.iterkeys()))
|
||||
|
||||
|
||||
|
@ -495,5 +495,13 @@ class ReadingTest(BaseTest):
|
||||
self.assertEqual(mi.format_field(field), pmi.format_field(field),
|
||||
'Custom field format: %s not the same for book %s' % (field, book_id))
|
||||
|
||||
# Test handling of recursive templates
|
||||
cache.create_custom_column('comp2', 'comp2', 'composite', False, display={'composite_template':'{title}'})
|
||||
cache.create_custom_column('comp1', 'comp1', 'composite', False, display={'composite_template':'foo{#comp2}'})
|
||||
cache.close()
|
||||
cache = self.init_cache()
|
||||
mi, pmi = cache.get_metadata(1), cache.get_proxy_metadata(1)
|
||||
self.assertEqual(mi.get('#comp1'), pmi.get('#comp1'))
|
||||
|
||||
# }}}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user