Models for TiddlyWeb Entities.
Classes representing the important entities in the TiddlyWeb system.
These are intentionally limited, making no effort to handle their own persistence or presentation. That is the job of the store and serializer.
A module containing the Bag class.
Bases: object
A Bag is a virtual container for tiddlers. The bag provides a domain for the tiddlers within identifying those tiddlers uniquely and optionally acting a topical, functional or authorization container for the tiddlers.
A bag can contain many tiddlers but every tiddler must have a different title. The canonical identifier of a tiddler is the combination of the containing bag’s name and the tiddler’s title.
Containership is achieved via association: There are no methods on a bag to access the contained tiddlers. These are found via store.list_bag_tiddlers.
A Bag has a Policy which may be used to control access to both the Bag and the tiddlers within. These controls are optional and are primarily designed for use within the web handlers.
Classes representing collections of bags, recipes and tiddlers.
Because the main reason for having a collection is to send it out over the web, the collections keep track of their last-modified time and generate a hash suitable for use as an ETag.
Bases: object
Base class for all collections.
Can be used directly for general collections if required.
A collection acts as generator, yielding one of its contents when iterated.
Add an item to the container, updating the digest and modified information.
Return the current hex representation of the hash digest of this collection.
Bases: tiddlyweb.model.collections.Collection
A collection of things which have a name attribute.
Bases: tiddlyweb.model.collections.Collection
A Collection specifically for tiddlers.
This differs from the base class in two ways:
The calculation of the digest is more detailed in order to create stong ETags for the collection.
When iterated, if store is set on the Collection, then a yielded tiddler will be loaded from the store to fill in all its attributes. When a tiddler is added to the collection, if it is already filled, a non-full copy is made and put into the collection. This is done to save memory and because often the data is not needed.
If collections.use_memory is True in config then the full tiddler is kept in the collection. On servers with adequate memory this can be more efficient.
Add a reference to the tiddler to the container, updating the digest and modified information. If the tiddler has recently been deleted, resulting in a StoreError, don’t add it.
A module containing the Policy class and associated exceptions.
Bases: tiddlyweb.model.policy.PermissionsError
The provided user cannot do this action.
Bases: exceptions.Exception
Base class for Policy violations.
Bases: object
A container for information about the contraints on a bag or recipe. Both are containers of tiddlers. We need to be able to control who can do what to do those tiddlers. We also need to be able to control who can manage those constraints.
The :pu:func:__init__ parameters represent a default policy.
There are six constraints plus one identifying attribute (owner). The constraints are listed below with descriptions of what is allowed if the constraint passes.
Is the user encapsulated by the usersign dict allowed to perform the action described by constraint. If so, return True. If not raise a UserRequiredError (if the user is GUEST) or ForbiddenError exception.
The dict has a name key with a string value which is a username and a roles key with a list of roles as its value. Either may match in the constraint. Usersign is usually populated during the CredentialsExtractor phase of a request.
For this policy return a list of constraints for which this usersign passes.
Bases: tiddlyweb.model.policy.PermissionsError
To do this action a user is required.
Determine if the user in usersign can create entity type.
The Recipe class.
Bases: object
A Recipe is an ordered list that represents a program for creating a collection of tiddlers.
Each line in the recipe is the combination of a bag name and a filter string. This implementation uses list of tuples.
In common usage a recipe contains only strings representing bags and filters, but for the sake of easy testing, the bag argument can be a Bag object.
A Recipe has a Policy which can be used to control access to the Recipe. These controls are optional and are primarily designed for use within the web handlers.
Return the recipe list, as a list of tuple pairs.
Set the contents of the recipe list.
A module containing the Tiddler class and related functions.
Bases: object
The primary content object in the TiddlyWiki and TiddlyWeb universe, representing a distinct piece of content, often vaguely corresponding to a Page in wiki systems. A Tiddler has text and some associated metadata. The text can be anything, often wikitext in some form, or Javascript code. It is possible for a Tiddler to container binary content, such as image data.
A Tiddler is intentionally solely a container of data. That is, it has no methods which change the state of attributes in the Tiddler or manipulate the tiddler. Changing the attributes is done by directly changing the attributes. This is done to make the Tiddler easier to store and serialize in many ways.
A Tiddler has several attributes:
Get the creator of this tiddler. If it has not been set then use modifier.
Use the creator property instead.
Translate the current UTC time into a TiddlyWiki conformat timestring.
Given a string representing tags (space-delimited, tags containing spaces are enclosed in in double brackets), parse them into a list of tag strings.
Duplicates are removed.
Given a list of tags, turn it into the canonical string representation (space-delimited, enclosing tags containing spaces in double brackets).
Turn a TiddlyWiki timestring into a datetime object.
Will raise ValueError if the input is not a 12 or 14 digit timestring.
A class representing a simple user entity.
A User object is not required during TiddlyWeb requests, credentials extractors and policies may work with arbitrary data for authentication and authorization. However if a locally stored user is required the User may be used.
Bases: object
A simple representation of a user. A user is a username, an optional password, an optional list of roles, and an optional note.
Add the named role (a string) to this user.
Check the password for this user. Return True if correct.
Remove the named role (a string) from this user. If it is not there, do nothing.
List (as a list of strings) the roles that this user has.
Set the password for this user.