werkzeug.environ_property
¶
-
class
werkzeug.
environ_property
(name, default=None, load_func=None, dump_func=None, read_only=None, doc=None)[source]¶ Maps request attributes to environment variables. This works not only for the Werzeug request object, but also any other class with an environ attribute:
>>> class Test(object): ... environ = {'key': 'value'} ... test = environ_property('key') >>> var = Test() >>> var.test 'value'
If you pass it a second value it’s used as default if the key does not exist, the third one can be a converter that takes a value and converts it. If it raises
ValueError
orTypeError
the default value is used. If no default value is provided None is used.Per default the property is read only. You have to explicitly enable it by passing
read_only=False
to the constructor.