Controllers - DefaultController
Description
SaWALi's default controller— tries to select a document from a database based on the HTTP request. The request has to be in any of the following formats in order to activate this controller:
/ - website root document.
/basename - root document of a specific database.
/basename/docname - a specific, non-root document within a specific database.
Properties
- document (instance | None)
- Instance of a Record from an instance of DocumentsBase.
- section (instance | None)
- Instance of a Record from an instance of DocSettingsBase.
Methods
- index (basename=None, docname=None)
- Sets the appropriate values for the `document` and `section` properties according to `basename` and `docname`. If the appropriate values cannot be set, responds with a 404 Not Found error page. Otherwise, responds with a rendered template.
- _check_for_preview (doc)
- A helper invoked by _get_document to see whether a non-public document (doc) can be viewed by an authenticated user; because she's the document's author or she's a website administrator. Returns True or False.
- _get_document (db, basename, docname)
- A helper invoked by index to select a specific document by its name. If the selected document is not-for-public viewing, checks whether the current user may view it. Sets the value of `document` on a successful selection.
- _get_section (basename)
- A helper invoked by index to select a section Record from DocSettingsBase and to instantiate the appropriate DocumentsBase. Sets the value of `section` on a successful selection.
- _set_context (db)
- A helper invoked by index to set the Mako engine's context based on `document's` properties and its model's (db) methods. Returns a rendered page that's based on whatever template `document` specifies.