Skip to content

Persistence of custom plugin state? #4817

Answered by sampsyo
gryphonmyers asked this question in Q&A
Discussion options

You must be logged in to vote

We actually do not have a general-purpose way to do this! It's common to attach attributes to items or albums for plugin-specific reasons, but we don't have a way that's unattached to the models.

You might consider taking inspiration from the way the importer saves its progress state, which is just storing a pickled data structure in the configuration directory:

beets/beets/importer.py

Lines 69 to 91 in 0c3f428

# Utilities.
def _open_state():
"""Reads the state file, returning a dictionary."""
try:
with open(config['statefile'].as_filename(), 'rb') as f:
return pickle.load(f)
except Exception as exc:
# The `pickle` module can emit all so…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gryphonmyers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants