gws.base.template.manager

Template manager.

Source code: gws.base.template.manager

Module Contents

class gws.base.template.manager.Object

Bases: gws.TemplateManager

Template manager.

find_template(subject, where, user=None, mime_type=None)

Find a template for a subject.

The templates of the objects in where are searched in the given order, then the application templates. A template without mimeTypes matches any MIME type.

Parameters:
  • subject – Template subject.

  • where – Objects whose templates are searched, in this order.

  • user – If given, only templates this user can use.

  • mime_type – If given, only templates which can produce this MIME type.

Returns:

The first matching template, or None.

find_templates(subjects, where, user=None, mime_type=None)

Find templates for several subjects.

Parameters:
  • subjects – Template subjects.

  • where – Objects whose templates are searched, in this order.

  • user – If given, only templates this user can use.

  • mime_type – If given, only templates which can produce this MIME type.

Returns:

Found templates, one per subject at most.

template_from_path(path, **kwargs)

Create a template from a file.

The template type is derived from the file extension.

Parameters:

path – File path.

Returns:

A template, or None if the file is not a template.

gws.base.template.manager.TEMPLATE_TYPES