gws.base.template.core

Base template object.

Source code: gws.base.template.core

Module Contents

class gws.base.template.core.Config(*args, **kwargs)

Bases: gws.ConfigWithAccess

Template configuration.

mapSize: gws.UomSizeStr | None

Size of the map on the page.

mimeTypes: list[gws.MimeType] | None

Output MIME types of the template.

pageMargin: gws.UomExtentStr | None

Page margins in the order top, right, bottom, left.

pageSize: gws.UomSizeStr | None

Page size.

subject: str = ''

Purpose of the template.

title: str = ''

Template title, shown in the client.

gws.base.template.core.DEFAULT_MAP_SIZE
gws.base.template.core.DEFAULT_PAGE_SIZE
class gws.base.template.core.Object

Bases: gws.Template

Base class for templates.

Reads the common template options: subject, title, output MIME types, page size, map size and page margins. Subclasses implement rendering; they can use prepare_args to build the template arguments with the locale, formatters and localized strings, and notify to report progress.

configure()

Configuration hook.

Called when the node is initialized. Raising an exception here aborts the creation of the node.

notify(tri: gws.TemplateRenderInput, message: str)

Send a progress message to the notify callback of the render input, if any.

Parameters:
  • tri – Template render input.

  • message – Progress message, like begin_print.

prepare_args(tri: gws.TemplateRenderInput) → gws.TemplateArgs

Build the template arguments from the render input.

Adds app, subject, locale, the date, time and number formatters, the obsolete gwsVersion and gwsBaseUrl, unless already given in tri.args. The locale is taken from the arguments, the render input, the first application locale or the default locale. STRINGS is set to the default strings for the locale language, updated with the given STRINGS.

Parameters:

tri – Template render input.

Returns:

Template arguments.

props(user)

Generate a Props struct for this object.

Do not call this method directly, use gws.props_of instead, which also checks permissions.

Parameters:

user – The user for which the props should be generated.

Returns:

A Props object or a dict. Nested objects are converted to props as well.

class gws.base.template.core.Props(*args, **kwargs)

Bases: gws.Props

Object properties.

mapSize: gws.Size | None
pageSize: gws.Size | None
title: str