Pluggable application to manage static pages (/about) on DB (sqlalchemy or ming) with RST or HTML
Project description
About flatpages
flatpages is a Pluggable application for TurboGears2 meant to simply management of simple static pages inside your TurboGears application.
Instead of creating a controller and template for “About”, “Contacts” and similar pages, just plug flatpages and edit them directly from the administration interface.
Installing
flatpages can be installed both from pypi or from bitbucket:
pip install tgapp-flatpages
should just work for most of the users
Plugging flatpages
In your application config/app_cfg.py import plug:
from tgext.pluggable import plug
Then at the end of the file call plug with flatpages:
plug(base_config, 'flatpages')
You will be able to access the plugged application management interface at http://localhost:8080/pages/manage while all the pages you create will be served at http://localhost:8080/pages/PAGENAME.
Restricting access to pages
flatpages supports restricting access to pages only to users that has a specific permission. When creating the page set it to Public, Only Registered Users or any of the Permission your application provides.
Loading pages from file
When working with static pages it’s often easier to include the starting version or new versions into the source code itself instead of providing a database migration each time the content has to be changed.
To allow this, flatpages permits to load the page content from a file local to the application itself. To do so it’s sufficient to set file://path/relative/to/application/package as the content of the static page.
Options
flatpages exposes some options to control the behavior when rendering a page, pass this to the plug call to set them:
format -> This is the format used to render the page content, can be html or rst if you store pages in RST or HTML format.
templates -> This is a list of the templates available to render the pages. Each entry is in the form: ("engine:package.templates.path", "Template Description").
Example of plugin using genshi as template engine:
plug(base_config, 'flatpages', format='html', templates=[("genshi:yourproject.templates.flatpages.page", "default")], global_models = True)
Overriding crud templates
you can find tgext.admin templates here: https://github.com/TurboGears/tgext.admin/tree/master/tgext/admin/templates/bootstrap_crud and override them in your app_cfg.py with something like:
replace_template(base_config, 'tgext.admin.templates.bootstrap_crud.get_all', 'myproject.templates.crud.get_all')
Hooks
flatpages exposes some hooks to control the behavior when rendering a page:
flatpages.before_override_template -> This is the hook called before the template gets overrided by the info, passed as args an object with page slug and self.
flatpages.after_override_template -> This is the hook called after the template gets overrided by the info, passed as args an object of FlatPage and self .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file tgapp-flatpages-0.3.2.tar.gz
.
File metadata
- Download URL: tgapp-flatpages-0.3.2.tar.gz
- Upload date:
- Size: 94.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3434cdf2692a3fc099848549572b5c5233935dfaf173270a194fec14eb891dd |
|
MD5 | 3f009396ef0dcd8d4c956e1660f2031d |
|
BLAKE2b-256 | a4738e3c55b95a3cb748713c448b56aba1c4e1e5b4e1f46adc49950d62a5b972 |