Models for TiddlyWeb Entities.
Psuedo-model classes representing the important entities/data classes in the TiddlyWeb system.
These are intentionally limited, making no effort to handle their own persistence or presentation. That is the job of other systems.
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 has a Policy (see tiddlyweb.model.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.
Collection classes.
These classes are used for containing the other model classes. 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 stuff if required.
A collection acts as generator, yield 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.
In TiddlyWeb this is for lists of bags and recipes.
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.
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, simply don’t add it.
A module containing the Policy class.
Bases: tiddlyweb.model.policy.PermissionsError
The provided user cannot do this action.
Bases: exceptions.Exception
Base class for policy violation problems.
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 say who can do what to do those tiddlers. We also need to be able to say who can manage those constraints.
The init parameters represent a default policy.
There are six constraints plus one identifying atrribute (owner). The constraints are listed below with descriptions of what is allowed if the constraint passes.
read – View this entity in lists. View the contained entities. write – Edit the contained entities that already exist. create – Create new entities in the container. delete – Remove a contained entity. manage – Change the policy itself. accept – Accept the entity into the container without requiring
validation.
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 and a filter string. For this implementation we have a 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.
A Recipe has a Policy (see tiddlyweb.policy) which may 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.
Set the contents of the list.
A module containing the Tiddler class and related functions.
Bases: object
The primary content object in the TiddlyWiki universe, vaguely corresponding to a Page in other wiki systems. A Tiddler has text and some associated metadata. The text can be anything, but is usually wikitext in some form, or Javascript code to be used as a plugin. It is possible for a Tiddler to container binary content, such as image data.
A Tiddler is intentionally just 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:
title: The name of the tiddler. Required. created: A string representing when this tiddler was
created.
tags: A list of strings that describe the tiddler. fields: An arbitrary dictionary of extended (custom) fields on the tiddler. text: The contents of the tiddler. A string. revision: The revision of this tiddler. The type of a revision
is unspecified.
Get the creator of this tiddler. If it has not been set then use modifier.
Use the creator property instead.
Translate (now) 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.
Given a list of tags, turn them into the canonical string representation (space-delimited, enclosing tags containing spaces in double brackets)
Turn a tiddler 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.
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.