Rename cached_frozen_children -> cached_tag_flat_dict.
This commit is contained in:
parent
b59c2700db
commit
21921dc8fc
2 changed files with 16 additions and 18 deletions
|
@ -112,7 +112,7 @@ class GroupableMixin:
|
|||
}
|
||||
self.photodb.sql_insert(table=self.group_table, data=data)
|
||||
|
||||
self.photodb._cached_frozen_children = None
|
||||
self.photodb._cached_tag_flat_dict = None
|
||||
|
||||
def add_children(self, members):
|
||||
for member in members:
|
||||
|
@ -137,7 +137,7 @@ class GroupableMixin:
|
|||
If True, all children will be deleted.
|
||||
Otherwise they'll just be raised up one level.
|
||||
'''
|
||||
self.photodb._cached_frozen_children = None
|
||||
self.photodb._cached_tag_flat_dict = None
|
||||
if delete_children:
|
||||
for child in self.get_children():
|
||||
child.delete(delete_children=True)
|
||||
|
@ -197,7 +197,7 @@ class GroupableMixin:
|
|||
'memberid': member.id,
|
||||
}
|
||||
self.photodb.sql_delete(table=self.group_table, pairs=pairs)
|
||||
self.photodb._cached_frozen_children = None
|
||||
self.photodb._cached_tag_flat_dict = None
|
||||
|
||||
def walk_children(self):
|
||||
'''
|
||||
|
@ -1219,7 +1219,7 @@ class Tag(ObjectBase, GroupableMixin):
|
|||
|
||||
self.photodb.log.debug('New synonym %s of %s', synname, self.name)
|
||||
|
||||
self.photodb._cached_frozen_children = None
|
||||
self.photodb._cached_tag_flat_dict = None
|
||||
|
||||
data = {
|
||||
'name': synname,
|
||||
|
@ -1242,7 +1242,7 @@ class Tag(ObjectBase, GroupableMixin):
|
|||
'''
|
||||
mastertag = self.photodb.get_tag(name=mastertag)
|
||||
|
||||
self.photodb._cached_frozen_children = None
|
||||
self.photodb._cached_tag_flat_dict = None
|
||||
|
||||
# Migrate the old tag's synonyms to the new one
|
||||
# UPDATE is safe for this operation because there is no chance of duplicates.
|
||||
|
@ -1295,7 +1295,7 @@ class Tag(ObjectBase, GroupableMixin):
|
|||
@decorators.transaction
|
||||
def delete(self, *, delete_children=False):
|
||||
self.photodb.log.debug('Deleting %s', self)
|
||||
self.photodb._cached_frozen_children = None
|
||||
self.photodb._cached_tag_flat_dict = None
|
||||
GroupableMixin.delete(self, delete_children=delete_children)
|
||||
self.photodb.sql_delete(table='photo_tag_rel', pairs={'tagid': self.id})
|
||||
self.photodb.sql_delete(table='tag_synonyms', pairs={'mastername': self.name})
|
||||
|
@ -1354,7 +1354,7 @@ class Tag(ObjectBase, GroupableMixin):
|
|||
if syn_exists is None:
|
||||
raise exceptions.NoSuchSynonym(synname)
|
||||
|
||||
self.photodb._cached_frozen_children = None
|
||||
self.photodb._cached_tag_flat_dict = None
|
||||
self.photodb.sql_delete(table='tag_synonyms', pairs={'name': synname})
|
||||
|
||||
@decorators.required_feature('tag.edit')
|
||||
|
@ -1375,7 +1375,7 @@ class Tag(ObjectBase, GroupableMixin):
|
|||
else:
|
||||
raise exceptions.TagExists(new_name)
|
||||
|
||||
self.photodb._cached_frozen_children = None
|
||||
self.photodb._cached_tag_flat_dict = None
|
||||
|
||||
data = {
|
||||
'id': self.id,
|
||||
|
|
|
@ -657,7 +657,6 @@ class PDBPhotoMixin:
|
|||
(tag_musts, tag_mays, tag_forbids, tag_expression) = tags_fixed
|
||||
|
||||
if tag_expression:
|
||||
frozen_children = self.get_cached_frozen_children()
|
||||
tag_expression_tree = searchhelpers.tag_expression_tree_builder(
|
||||
tag_expression=tag_expression,
|
||||
photodb=self,
|
||||
|
@ -668,6 +667,7 @@ class PDBPhotoMixin:
|
|||
tag_expression = None
|
||||
else:
|
||||
giveback_tag_expression = str(tag_expression_tree)
|
||||
frozen_children = self.get_cached_tag_flat_dict()
|
||||
tag_match_function = searchhelpers.tag_expression_matcher_builder(frozen_children)
|
||||
else:
|
||||
giveback_tag_expression = None
|
||||
|
@ -1121,7 +1121,7 @@ class PDBTagMixin:
|
|||
|
||||
author_id = self.get_user_id_or_none(author)
|
||||
|
||||
self._uncache()
|
||||
self._cached_tag_flat_dict = None
|
||||
|
||||
data = {
|
||||
'id': tag_id,
|
||||
|
@ -1636,7 +1636,7 @@ class PhotoDB(
|
|||
self.log.setLevel(self.config['log_level'])
|
||||
|
||||
# OTHER
|
||||
self._cached_frozen_children = None
|
||||
self._cached_tag_flat_dict = None
|
||||
|
||||
self.caches = {
|
||||
'album': cacheclass.Cache(maxlen=self.config['cache_size']['album']),
|
||||
|
@ -1678,9 +1678,6 @@ class PhotoDB(
|
|||
else:
|
||||
return f'PhotoDB(data_directory={self.data_directory})'
|
||||
|
||||
def _uncache(self):
|
||||
self._cached_frozen_children = None
|
||||
|
||||
def close(self):
|
||||
# Wrapped in hasattr because if the object fails __init__, Python will
|
||||
# still call __del__ and thus close(), even though the attributes
|
||||
|
@ -1724,10 +1721,11 @@ class PhotoDB(
|
|||
self.sql_update(table='id_numbers', pairs=pairs, where_key='tab')
|
||||
return new_id
|
||||
|
||||
def get_cached_frozen_children(self):
|
||||
if self._cached_frozen_children is None:
|
||||
self._cached_frozen_children = tag_export.flat_dict(self.get_tags())
|
||||
return self._cached_frozen_children
|
||||
def get_cached_tag_flat_dict(self):
|
||||
if self._cached_tag_flat_dict is None:
|
||||
self._cached_tag_flat_dict = tag_export.flat_dict(self.get_root_tags())
|
||||
print(len(self._cached_tag_flat_dict))
|
||||
return self._cached_tag_flat_dict
|
||||
|
||||
def load_config(self):
|
||||
(config, needs_rewrite) = configlayers.load_file(
|
||||
|
|
Loading…
Reference in a new issue