election_day.directives
Classes
Base class for protocol classes. |
|
HTML directive for manage views which makes sure the permission is set |
|
HTML directive for manage forms which makes sure the permission is set |
|
View directive for viewing SVG files from filestorage. The SVGs |
|
View directive for viewing PDF files from filestorage. The PDFs |
|
View directive for viewing JSON data as file. |
|
View directive for viewing CSV data as file. |
|
dict() -> new empty dictionary |
|
Register a screen widget. |
Functions
|
|
|
|
|
|
|
Module Contents
- class election_day.directives.InputScreenWidget[source]
Bases:
ProtocolBase class for protocol classes.
Protocol classes are defined as:
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example:
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:
class GenProto[T](Protocol): def meth(self) -> T: ...
- class election_day.directives.ManageHtmlAction(model: type | str, render: collections.abc.Callable[[Any, RequestT], webob.Response] | str | None = None, template: _typeshed.StrOrBytesPath | None = None, load: collections.abc.Callable[[RequestT], Any] | str | None = None, permission: object | str | None = None, internal: bool = False, **predicates: Any)[source]
Bases:
morepath.directive.HtmlActionHTML directive for manage views which makes sure the permission is set to private.
- class election_day.directives.ManageFormAction(model: type | str, form: type[wtforms.Form] | collections.abc.Callable[[Any, RequestT], type[wtforms.Form]] = EmptyForm, render: collections.abc.Callable[[Any, RequestT], webob.Response] | str | None = None, template: _typeshed.StrOrBytesPath = 'form.pt', load: collections.abc.Callable[[RequestT], Any] | str | None = None, permission: object | str | None = None, internal: bool = False, **predicates: Any)[source]
Bases:
onegov.core.directives.HtmlHandleFormActionHTML directive for manage forms which makes sure the permission is set to private. Sets a valid default for the template and form class.
- election_day.directives.render_svg(content: dict[str, Any], request: onegov.core.request.CoreRequest) morepath.request.Response[source]
- election_day.directives.render_pdf(content: dict[str, Any], request: onegov.core.request.CoreRequest) morepath.request.Response[source]
- election_day.directives.render_json(content: dict[str, Any], request: onegov.core.request.CoreRequest) morepath.request.Response[source]
- election_day.directives.render_csv(content: dict[str, Any], request: onegov.core.request.CoreRequest) morepath.request.Response[source]
- class election_day.directives.SvgFileViewAction(model: type | str, load: collections.abc.Callable[[RequestT], Any] | str | None = None, permission: object | str = Public, internal: bool = False, **predicates: Any)[source]
Bases:
morepath.directive.ViewActionView directive for viewing SVG files from filestorage. The SVGs are created using a cronjob and might not be available.
- class election_day.directives.PdfFileViewAction(model: type | str, load: collections.abc.Callable[[RequestT], Any] | str | None = None, permission: object | str = Public, internal: bool = False, **predicates: Any)[source]
Bases:
morepath.directive.ViewActionView directive for viewing PDF files from filestorage. The PDFs are created using a cronjob and might not be available.
- class election_day.directives.JsonFileAction(model: type | str, load: collections.abc.Callable[[RequestT], Any] | str | None = None, permission: object | str = Public, internal: bool = False, **predicates: Any)[source]
Bases:
morepath.directive.ViewActionView directive for viewing JSON data as file.
- class election_day.directives.CsvFileAction(model: type | str, load: collections.abc.Callable[[RequestT], Any] | str | None = None, permission: object | str = Public, internal: bool = False, **predicates: Any)[source]
Bases:
morepath.directive.ViewActionView directive for viewing CSV data as file.
- class election_day.directives.ScreenWidgetRegistry[source]
Bases:
dict[str,dict[str,ScreenWidget]]dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s
(key, value) pairs
- dict(iterable) -> new dictionary initialized as if via:
d = {} for k, v in iterable:
d[k] = v
- dict(**kwargs) -> new dictionary initialized with the name=value pairs
in the keyword argument list. For example: dict(one=1, two=2)
- class election_day.directives.ScreenWidgetAction(tag: str, category: str)[source]
Bases:
dectate.ActionRegister a screen widget.
- config[source]
Describe configuration.
A dict mapping configuration names to factory functions. The resulting configuration objects are passed into
Action.identifier(),Action.discriminators(),Action.perform(), andAction.before()andAction.after().After commit completes, the configured objects are found as attributes on
App.config.
- identifier(screen_widget_registry: ScreenWidgetRegistry) str[source]
Returns an immutable that uniquely identifies this config.
Needs to be implemented by the
Actionsubclass.Used for overrides and conflict detection.
If two actions in the same group have the same identifier in the same configurable, those two actions are in conflict and a
ConflictErroris raised duringcommit().If an action in an extending configurable has the same identifier as the configurable being extended, that action overrides the original one in the extending configurable.
- Parameters:
**kw – a dictionary of configuration objects as specified by the
configclass attribute.- Returns:
an immutable value uniquely identifying this action.
- perform(func: collections.abc.Callable[[], InputScreenWidget], screen_widget_registry: ScreenWidgetRegistry) None[source]
Do whatever configuration is needed for
obj.Needs to be implemented by the
Actionsubclass.Raise a
DirectiveErrorto indicate that the action cannot be performed due to incorrect configuration.- Parameters:
obj – the object that the action should be performed for. Typically a function or a class object.
**kw – a dictionary of configuration objects as specified by the
configclass attribute.