OpenQuizz
Une application de gestion des contenus pédagogiques
flask_restful Namespace Reference

Namespaces

 __version__
 
 fields
 
 inputs
 
 representations
 
 reqparse
 
 utils
 

Data Structures

class  Api
 
class  marshal_with
 
class  marshal_with_field
 
class  Resource
 

Functions

def abort (http_status_code, **kwargs)
 
def marshal (data, fields, envelope=None)
 

Variables

list DEFAULT_REPRESENTATIONS = [('application/json', output_json)]
 

Function Documentation

◆ abort()

def flask_restful.abort (   http_status_code,
**  kwargs 
)
Raise a HTTPException for the given http_status_code. Attach any keyword
arguments to the exception for later processing.

◆ marshal()

def flask_restful.marshal (   data,
  fields,
  envelope = None 
)
Takes raw data (in the form of a dict, list, object) and a dict of
fields to output and filters the data based on those fields.

:param data: the actual object(s) from which the fields are taken from
:param fields: a dict of whose keys will make up the final serialized
               response output
:param envelope: optional key that will be used to envelop the serialized
                 response


>>> from flask_restful import fields, marshal
>>> data = { 'a': 100, 'b': 'foo' }
>>> mfields = { 'a': fields.Raw }

>>> marshal(data, mfields)
OrderedDict([('a', 100)])

>>> marshal(data, mfields, envelope='data')
OrderedDict([('data', OrderedDict([('a', 100)]))])

Variable Documentation

◆ DEFAULT_REPRESENTATIONS

list DEFAULT_REPRESENTATIONS = [('application/json', output_json)]