Avoid overeager inclusion of album attributes

Co-Authored-By: Curtis Rueden <ctrueden@wisc.edu>
This commit is contained in:
FichteFoll 2020-11-02 01:06:05 +01:00
parent 701cd6c42b
commit 2d024d2f38
No known key found for this signature in database
GPG key ID: 9FA3981C07CD83C5
2 changed files with 5 additions and 3 deletions

View file

@ -56,10 +56,11 @@ class FormattedMapping(Mapping):
are replaced.
"""
def __init__(self, model, for_path=False):
def __init__(self, model, for_path=False, compute_keys=True):
self.for_path = for_path
self.model = model
self.model_keys = model.keys(True)
if compute_keys:
self.model_keys = model.keys(True)
def __getitem__(self, key):
if key in self.model_keys:

View file

@ -375,9 +375,10 @@ class FormattedItemMapping(dbcore.db.FormattedMapping):
"""
def __init__(self, item, for_path=False):
super(FormattedItemMapping, self).__init__(item, for_path)
# We treat album and item keys specially here,
# so exclude transitive album keys from the model's keys.
super(FormattedItemMapping, self).__init__(item, for_path,
compute_keys=False)
self.model_keys = item.keys(computed=True, with_album=False)
self.item = item