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

Public Member Functions

def __init__ (self, mapping, required=False, **kwargs)
 
def output (self, key, obj, ordered=False, **kwargs)
 
def resolve_ancestor (self, models)
 
def clone (self, mask=None)
 
- Public Member Functions inherited from Nested
def __init__ (self, model, allow_null=False, skip_none=False, as_list=False, **kwargs)
 
def nested (self)
 
def schema (self)
 
- Public Member Functions inherited from Raw
def __init__ (self, default=None, attribute=None, title=None, description=None, required=None, readonly=None, example=None, mask=None, **kwargs)
 
def format (self, value)
 
def output (self, key, obj, **kwargs)
 
def __schema__ (self)
 

Data Fields

 mapping
 
- Data Fields inherited from Nested
 model
 
 as_list
 
 allow_null
 
 skip_none
 
- Data Fields inherited from Raw
 attribute
 
 default
 
 title
 
 description
 
 required
 
 readonly
 
 example
 
 mask
 

Detailed Description

A Nested field handling inheritance.

Allows you to specify a mapping between Python classes and fields specifications.

.. code-block:: python

    mapping = {
        Child1: child1_fields,
        Child2: child2_fields,
    }

    fields = api.model('Thing', {
        owner: fields.Polymorph(mapping)
    })

:param dict mapping: Maps classes to their model/fields representation

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  mapping,
  required = False,
**  kwargs 
)

Member Function Documentation

◆ clone()

def clone (   self,
  mask = None 
)

Reimplemented from Nested.

◆ output()

def output (   self,
  key,
  obj,
  ordered = False,
**  kwargs 
)

Reimplemented from Nested.

◆ resolve_ancestor()

def resolve_ancestor (   self,
  models 
)
Resolve the common ancestor for all models.

Assume there is only one common ancestor.

Field Documentation

◆ mapping

mapping

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