annals.prefs#
Each reader’s page preferences: a few named sections of JSON, kept on the server.
The page’s settings (the order of a document’s actions, first) follow the reader from the
phone to the tablet to the desktop, and from Safari to the home-screen app, which on an
iPhone keep separate browser storage. So they live here, one JSON file per reader beside the
listening records (<root>/prefs/<reader>.json), and the page keeps a copy in the browser
only to draw its first screen.
The page owns what a section means: its schema, defaults and the merge of a saved value with
a newer default are in app.js (SETTINGS). The server keeps each section as the
reader left it, refusing only what no section could be: a name that is not a short slug, a
value that is not a JSON object, a section over MAX_SECTION_BYTES, or more than
MAX_SECTIONS sections. That keeps a new setting a page-only change.
>>> clean_section("bar", {"order": ["links", "listen"]})
{'order': ['links', 'listen']}
>>> clean_section("Bar!", {})
Traceback (most recent call last):
...
ValueError: a section name is a lower-case slug of at most 32 characters
Functions
|
|
|
The default seam: each reader's preferences in |
|
Keep |
Classes
|
One reader's preferences: |
- class annals.prefs.PrefsStore(path)[source]#
Bases:
JsonFileStoreOne reader’s preferences:
{section: object}in one JSON file.
- annals.prefs.clean_section(name, value)[source]#
valueas kept undername, orValueErrorsaying why it cannot be.- Return type: