Turn entities to and fro various representations.
This is the base class and interface class used to transform strings of various forms to model objects and model objects to strings of various forms.
Bases: object
A Serialization is a collection of methods that either turn an input string into the object named by the method, or turn the object into a string form. A Serialization is not called directly, instead a Serializer facade is used.
The interface is fairly simple: For the core entities that exist in the TiddlyWeb system (bags, recipes and tiddlers there (optionally) exists <entity>_as and as_<entity> methods in each Serialization.
*_as returns a string form of the entity, perhaps as HTML, Text, YAML, Atom, whatever the Serialization does.
as_* takes a provided entity and string and updates the skeletal entity to use the information contained in the string (in the Serialization format).
There are also three supporting methods, list_tiddlers(), list_recipes() and list_bags() that provide convenience methods for presenting a collection of entities in the Serialization form. A string is returned.
Strings are usually unicode.
If a method doesn’t exist a NoSerializationError is raised and the calling code is expected to do something intelligent when trapping it.
Take input_string which is a serialized bag and use it to populate the Bag in bag (if possible).
Take input_string which is a serialized recipe and use it to populate the Recipe in recipe (if possible).
Not called directly, but made public for future use. Turn a string into a list of tags.
Take input_string which is a serialized tiddler and use it to populate the Tiddler in tiddler (if possible).
Provided a list of bags, make a serialized list of those bags (e.g. a a list of HTML links).
Provided a list of recipes, make a serialized list of those recipes (e.g. a a list of HTML links).
Not called directly, but made public for future use. Turn a list of tags into a serialized list.
Serialization for HTML.
HEADER and FOOTER can be overridden to change the basic framing of the system.
Bases: tiddlyweb.serializations.SerializationInterface
Serialize entities and collections to HTML representations. This is primarily used to create browser based presentations. No support is provided for turning HTML into entities.
Set css_uri in config to control CSS.
Set tiddlyweb.links in environ to a list of <link> elements to include those links in the output.
Serialization for JSON.
Bases: tiddlyweb.serializations.SerializationInterface
Turn entities and collections thereof to and from JSON.
Turn a JSON dictionary into a bag if it is in the proper form. Include the policy.
Turn a JSON dictionary into a recipe if it is in the proper form. Include the policy.
Turn a JSON dictionary into a tiddler. Any keys in the JSON which are not recognized will be ignored.
List the provided tiddlers as JSON. The format is a list of dicts in the form described by _tiddler_dict().
If fat=1 is set in tiddlyweb.query include the text of each tiddler in the output.
If render=1 is set in tiddlyweb.query include the rendering of the text of each tiddler in the output, if the tiddler is renderable.
Create a JSON dictionary representing a tiddler, as described by _tiddler_dict() plus the text of the tiddler.
If fat=0 is set in tiddlyweb.query do not include the text of the tiddler in the output.
If render=1 is set in tiddlyweb.query include the rendering of the text of the tiddler in the output, if the tiddler is renderable.
Serialization for plain text.
Bases: tiddlyweb.serializations.SerializationInterface
Serialize entities and collections to and from textual representations. This is primarily used by the text Store.
Transform a text representation of a tiddler into a tiddler object.
Return a linefeed separated list of tiddler titles in the tiddlers list.
If the tiddlers are a collection of revisions, include the revision identifier.
Represent a tiddler as a text string: headers, blank line, text.
omit_* arguments are non-standard options, usable only when this method is called directly (outside the regular Serializer interface)
If omit_empty is True, don’t emit empty Tiddler members.
omit_members can be used to provide a list of members to not include in the output.