OpenQuizz
Une application de gestion des contenus pédagogiques
jinja2.sandbox Namespace Reference

Data Structures

class  _MagicFormatMapping
 
class  ImmutableSandboxedEnvironment
 
class  SandboxedEnvironment
 
class  SandboxedEscapeFormatter
 
class  SandboxedFormatter
 
class  SandboxedFormatterMixin
 

Functions

def inspect_format_method (callable)
 
def safe_range (*args)
 
def unsafe (f)
 
def is_internal_attribute (obj, attr)
 
def modifies_known_mutable (obj, attr)
 
def formatter_field_name_split (field_name)
 

Variables

 MAX_RANGE
 
 UNSAFE_FUNCTION_ATTRIBUTES
 
 UNSAFE_METHOD_ATTRIBUTES
 
 UNSAFE_GENERATOR_ATTRIBUTES
 
 UNSAFE_COROUTINE_ATTRIBUTES
 
 UNSAFE_ASYNC_GENERATOR_ATTRIBUTES
 
 DeprecationWarning
 
 module
 

Function Documentation

◆ formatter_field_name_split()

def jinja2.sandbox.formatter_field_name_split (   field_name)

◆ inspect_format_method()

def jinja2.sandbox.inspect_format_method (   callable)

◆ is_internal_attribute()

def jinja2.sandbox.is_internal_attribute (   obj,
  attr 
)
Test if the attribute given is an internal python attribute.  For
example this function returns `True` for the `func_code` attribute of
python objects.  This is useful if the environment method
:meth:`~SandboxedEnvironment.is_safe_attribute` is overridden.

>>> from jinja2.sandbox import is_internal_attribute
>>> is_internal_attribute(str, "mro")
True
>>> is_internal_attribute(str, "upper")
False

◆ modifies_known_mutable()

def jinja2.sandbox.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.  It also supports
the "user"-versions of the objects (`sets.Set`, `UserDict.*` etc.) and
with Python 2.6 onwards the abstract base classes `MutableSet`,
`MutableMapping`, and `MutableSequence`.

>>> modifies_known_mutable({}, "clear")
True
>>> modifies_known_mutable({}, "keys")
False
>>> modifies_known_mutable([], "append")
True
>>> modifies_known_mutable([], "index")
False

If called with an unsupported object (such as unicode) `False` is
returned.

>>> modifies_known_mutable("foo", "upper")
False

◆ safe_range()

def jinja2.sandbox.safe_range ( args)
A range that can't generate ranges with a length of more than
MAX_RANGE items.

◆ unsafe()

def jinja2.sandbox.unsafe (   f)
Marks a function or method as unsafe.

::

    @unsafe
    def delete(self):
        pass

Variable Documentation

◆ DeprecationWarning

DeprecationWarning

◆ MAX_RANGE

MAX_RANGE

◆ module

module

◆ UNSAFE_ASYNC_GENERATOR_ATTRIBUTES

UNSAFE_ASYNC_GENERATOR_ATTRIBUTES

◆ UNSAFE_COROUTINE_ATTRIBUTES

UNSAFE_COROUTINE_ATTRIBUTES

◆ UNSAFE_FUNCTION_ATTRIBUTES

UNSAFE_FUNCTION_ATTRIBUTES

◆ UNSAFE_GENERATOR_ATTRIBUTES

UNSAFE_GENERATOR_ATTRIBUTES

◆ UNSAFE_METHOD_ATTRIBUTES

UNSAFE_METHOD_ATTRIBUTES