bin.models module¶
Mapping between python objets and the Redis store
- class bin.models.Snippet(ident, code, views_left, parentid, token)¶
A snippet is a immuable text that have been saved in the database and that is retrivable via an unique URL.
- code¶
snippet text
- classmethod create(code, maxusage, lifetime, parentid, token=None)¶
Save a snippet in the database and return a snippet object
- Parameters
code – the source code utf-8 encoded
maxusage – how many times this snippet can be retrieve before self-deletion
lifetime – how long the snippet is saved before self-deletion
parentid – the original snippet id this new snippet is a duplicate of, empty string for original snippet
token – the “admin” token of the snippet,
Noneif the snippet has no “admin” token
- delete()¶
Delete the snippet from the database
- classmethod get_by_id(ident)¶
Retrieve a snippet from the database and return a snippet object
- Parameters
ident – the snippet identifier
- Raises
KeyError – the snippet does not exist or have been removed
- id¶
snippet unique identifier
- classmethod new_id()¶
Generate a safe unique identifier
- parentid¶
the original snippet this one is a duplicate of or an empty string
- token¶
the admin token of the snippet
- views_left¶
how many time this snippet can be retrieved again