Models - DocumentsBase
Description
Derived from BaseModel, this model defines SaWALi's document structures.
Properties
All inherited from BaseModel.
Database Schema
- [buzhug record default properties]
- These include __id__, __version__, etc.
- author (Integer, 0)
- __id__ of the user's record (see UsersBase).
- parent (Integer, 0)
- __id__ of a document record (in this database).
- name (Unicode)
- A short, unique, alphanumeric (plus underscores) unicode value that is used to identify a document.
- title (Unicode)
- The document's full title.
- body (Unicode)
- The document's body (HTML).
- date_made (Float, BaseModel.calltime)
- The date (in seconds) when the document was created.
- date_edit (Float, BaseModel.calltime)
- The date (in seconds) when the document was last saved.
- css (Unicode)
- Document-specific Cascading Style Sheet.
- js (Unicode)
- Document-specific JavaScript.
- description (Unicode)
- Description/summary of the document's contents.
- keywords (Unicode)
- Comma-separated keywords and key phrases.
- sort_siblings (Unicode, u"-__id__")
- A sort_by argument for when selecting the document's siblings.
- sort_children (Unicode, u"-__id__")
- A sort_by argument for when selecting the document's children.
- template (Unicode, u"default.html")
- The template to be used for rendering the document, must be in "templates/public".
- allow_comments (Boolean, False)
- Whether to accept and display comments for this document (not yet implemented).
Methods
- __init__ (basename)
- Initialises the BaseModel super-class passing "Documents" as the prefix and the specified basename.
- _create_schema
- Override to BaseModel._create_schema, see Database Schema heading. Additionally, this method, when invoked, inserts the "root" document.
- _gen_ref (basename, docname)
- A helper that generates the value for HTML href attributes.
- _normalise_contents (record)
- A helper that removes unnessary (for Mako) HTML entities from a record's unicode fields.
- _update_ancestors (parent_id)
- A helper that recursively updates the date_edit values of a records ancestors, starting with its parent.
- get (name_or_id, public_only=True)
- Tries to select a record based on its name or __id__, and whether it is for public viewing. public_only is set to False by controller methods that respond with an editor form for administrators and document authors.
- get_articles (limit, children)
- Returns a list of dictionaries, which are used to provide more context to the Mako engine. The number of dictionaries to be returned is less than limit.
- get_menu_items (doc, for_cms=False)
- Returns a 3-tuple that provides the Mako engine with additional the context for a document's (doc) parent, siblings, and children. for_cms tells this method whether to use filters, which are typically not necessary when an administrative interface is being used.
- remove_document (doc_id)
- Deletes a document record from the database.
- validate_and_update (doc, post_info, owner)
- Used through an administrative interface. Validates POST information and updates the properties of a document accordingly. `owner` is an integer— the __id__ of the user's record (see UsersBase).