jinja2.sandbox¶
Adds a sandbox layer to Jinja as it was the default behavior in the old Jinja 1 releases. This sandbox is slightly different from Jinja 1 as the default behavior is easier to use.
The behavior can be changed by subclassing the environment.
| copyright: |
|
|---|---|
| license: | BSD. |
Functions¶
is_internal_attribute(obj, attr) |
Test if the attribute given is an internal python attribute. |
modifies_known_mutable(obj, attr) |
This function checks if an attribute on a builtin mutable object (list, dict, set or deque) would modify it if called. |
safe_range(*args) |
A range that can’t generate ranges with a length of more than MAX_RANGE items. |
unsafe(f) |
Marks a function or method as unsafe. |
Classes¶
DictMixin |
|
Environment([block_start_string, ...]) |
The core component of Jinja is the Environment. |
ImmutableSandboxedEnvironment(*args, **kwargs) |
Works exactly like the regular SandboxedEnvironment but does not permit modifications on the builtin mutable objects list, set, and dict by using the modifies_known_mutable() function. |
MutableMapping |
A MutableMapping is a generic container for associating key/value pairs. |
MutableSequence |
All the operations on a read-only sequence. |
MutableSet |
A mutable set is a finite, iterable container. |
SandboxedEnvironment(*args, **kwargs) |
The sandboxed environment. |
Set([iterable]) |
Mutable set class. |
UserDict(*args, **kwargs) |
|
UserList([initlist]) |
|
deque |
deque([iterable[, maxlen]]) –> deque object |
Exceptions¶
SecurityError([message]) |
Raised if a template tries to do something insecure if the sandbox is enabled. |