API Docs

Static pages module for Invenio.

class invenio_pages.ext.InvenioPages(app=None)[source]

Invenio-Pages extension.

Extension initialization.

Parameters:app – The Flask application. (Default: None)
init_app(app)[source]

Flask application initialization.

Parameters:app – The Flask application.
Returns:The invenio_pages.ext.InvenioPages instance initialized.
init_config(app)[source]

Initialize configuration.

Parameters:app – The Flask application.
static wrap_errorhandler(app)[source]

Wrap error handler.

Parameters:app – The Flask application.

Configuration

Page module config.

invenio_pages.config.PAGES_DEFAULT_TEMPLATE = 'invenio_pages/default.html'

Default template to render.

invenio_pages.config.PAGES_TEMPLATES = [('invenio_pages/default.html', 'Default'), ('invenio_pages/dynamic.html', 'Default dynamic')]

List of available templates for pages.

invenio_pages.config.PAGES_WHITELIST_CONFIG_KEYS = ['THEME_SITENAME']

List of configuration variables accessible in the dynamic pages.

Models

Pages module models.

class invenio_pages.models.Page(**kwargs)[source]

Represents a page.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

content

Page content. Default is pages/templates/default.html

description

Page description.

classmethod get_by_url(url)[source]

Get a page by URL.

Parameters:url – The page URL.
Returns:A invenio_pages.models.Page instance.
id

Page identifier.

template_name

Page template name.

title

Page title.

url

Page url.

validate_template_name(key, value)[source]

Validate template name.

Parameters:
  • key – The template path.
  • value – The template name.
Raises:

ValueError – If template name is wrong.

class invenio_pages.models.PageList(**kwargs)[source]

Represent association between page and list.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

id

PageList identifier.

list

Relation to the list.

list_id

Id of a list.

page

Relation to the page.

page_id

Id of a page.

Views

Views for Pages module.

invenio_pages.views.handle_not_found(exception, **extra)[source]

Custom blueprint exception handler.

invenio_pages.views.preload_pages()[source]

Register all pages before the first application request.

invenio_pages.views.render_page(path)[source]

Internal interface to the page view.

Parameters:path – Page path.
Returns:The rendered template.
invenio_pages.views.render_string(source)[source]

Render a string in sandboxed environment.

Parameters:source – A string containing the page source.
Returns:The rendered template.
invenio_pages.views.view()[source]

Public interface to the page view.

Models: pages.pages. Templates: Uses the template defined by the template_name field or pages/default.html if template_name is not defined. Context: page pages.pages object.