morepath.converter
– Convert URL variables¶
Convert path variables and URL parameters to Python objects.
This module contains functionality that can convert traject and URL
parameters (?foo=3
) into Python values (ints, date, etc) that are
passed into model factories that are configured using the
morepath.App.path()
and morepath.App.mount()
directives. The inverse conversion back from Python value to string
also needs to be provided to support link generation.
morepath.Converter
is exported to the public API.
See also morepath.directive.ConverterRegistry
-
class
morepath.converter.
ListConverter
(converter)¶ How to decode from list of strings to list of objects and back.
Used
morepath.converter.ConverterRegistry
to handle lists of repeated names in parameters.Used for decoding/encoding URL parameters and path variables.
Create new converter.
Parameters: converter – the converter to use for list entries -
decode
(strings)¶ Decode list of strings into list of Python values.
Parameters: strings – list of strings Returns: list of Python values
-
encode
(values)¶ Encode list of Python values into list of strings
Parameters: values – list of Python values. Returns: List of strings.
-
is_missing
(value)¶ True is a given value is the missing value.
-
-
morepath.converter.
IDENTITY_CONVERTER
= <morepath.converter.Converter object>¶ Converter that has no effect.
String becomes string.