OpenQuizz
Une application de gestion des contenus pédagogiques
FormattedString Class Reference
Inheritance diagram for FormattedString:
Collaboration diagram for FormattedString:

Public Member Functions

def __init__ (self, src_str)
 
def output (self, key, obj)
 
- Public Member Functions inherited from Raw
def __init__ (self, default=None, attribute=None)
 
def format (self, value)
 

Data Fields

 src_str
 
- Data Fields inherited from Raw
 attribute
 
 default
 

Detailed Description

FormattedString is used to interpolate other values from
the response into this field. The syntax for the source string is
the same as the string :meth:`~str.format` method from the python
stdlib.

Ex::

    fields = {
        'name': fields.String,
        'greeting': fields.FormattedString("Hello {name}")
    }
    data = {
        'name': 'Doug',
    }
    marshal(data, fields)

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  src_str 
)
:param string src_str: the string to format with the other
values from the response.

Member Function Documentation

◆ output()

def output (   self,
  key,
  obj 
)
Pulls the value for the given key from the object, applies the
field's formatting and returns the result. If the key is not found
in the object, returns the default value. Field classes that create
values which do not require the existence of the key in the object
should override this and return the desired value.

:exception MarshallingException: In case of formatting problem

Reimplemented from Raw.

Field Documentation

◆ src_str

src_str

The documentation for this class was generated from the following file: