Python marshmallow.post_load() Examples

The following are 10 code examples of marshmallow.post_load(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module marshmallow , or try the search function .
Example #1
Source File: pagination.py    From flask-smorest with MIT License 5 votes vote down vote up
def _pagination_parameters_schema_factory(
        def_page, def_page_size, def_max_page_size):
    """Generate a PaginationParametersSchema"""

    class PaginationParametersSchema(ma.Schema):
        """Deserializes pagination params into PaginationParameters"""

        class Meta:
            ordered = True
            if MARSHMALLOW_VERSION_MAJOR < 3:
                strict = True
            else:
                unknown = ma.EXCLUDE

        page = ma.fields.Integer(
            missing=def_page,
            validate=ma.validate.Range(min=1)
        )
        page_size = ma.fields.Integer(
            missing=def_page_size,
            validate=ma.validate.Range(min=1, max=def_max_page_size)
        )

        @ma.post_load
        def make_paginator(self, data, **kwargs):
            return PaginationParameters(**data)

    return PaginationParametersSchema 
Example #2
Source File: schemas.py    From sota-extractor with Apache License 2.0 5 votes vote down vote up
def post_load(self, data, **kwargs):
        return Link(**data) 
Example #3
Source File: schemas.py    From sota-extractor with Apache License 2.0 5 votes vote down vote up
def post_load(self, data, **kwargs):
        return SotaRow(**data) 
Example #4
Source File: schemas.py    From sota-extractor with Apache License 2.0 5 votes vote down vote up
def post_load(self, data, **kwargs):
        return Sota(**data) 
Example #5
Source File: schemas.py    From sota-extractor with Apache License 2.0 5 votes vote down vote up
def post_load(self, data, **kwargs):
        dataset = Dataset(**data)
        for subdataset in dataset.subdatasets:
            subdataset.parent = dataset
        return dataset 
Example #6
Source File: schemas.py    From sota-extractor with Apache License 2.0 5 votes vote down vote up
def post_load(self, data, **kwargs):
        task = Task(**data)
        for subtask in task.subtasks:
            subtask.parent = task
        return task 
Example #7
Source File: schema.py    From lux with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _load(self, data):
        return self.post_load(data) 
Example #8
Source File: schema.py    From lux with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def post_load(self, data):
        return data 
Example #9
Source File: schema.py    From diffy with Apache License 2.0 5 votes vote down vote up
def post_load(self, data):
        data["plugin"] = resolve_plugin_slug(data["slug"])
        data["options"] = data["plugin"].validate_options(data["options"])
        return data 
Example #10
Source File: marshmallow.py    From flask-unchained with MIT License 4 votes vote down vote up
def __init__(self):
        self.Serializer = flask_ma.Schema
        self.ModelSerializer = ModelSerializer

        # alias marshmallow stuffs
        self.pre_load = ma.pre_load
        self.post_load = ma.post_load
        self.pre_dump = ma.pre_dump
        self.post_dump = ma.post_dump
        self.validates = ma.validates
        self.validates_schema = ma.validates_schema
        self.ValidationError = ma.ValidationError

        # alias marshmallow fields
        self.Bool = ma.fields.Bool
        self.Boolean = ma.fields.Boolean
        self.Constant = ma.fields.Constant
        self.Date = ma.fields.Date
        self.DateTime = ma.fields.DateTime
        self.NaiveDateTime = ma.fields.NaiveDateTime
        self.AwareDateTime = ma.fields.AwareDateTime
        self.Decimal = ma.fields.Decimal
        self.Dict = ma.fields.Dict
        self.Email = ma.fields.Email
        self.Field = ma.fields.Field
        self.Float = ma.fields.Float
        self.Function = ma.fields.Function
        self.Int = ma.fields.Int
        self.Integer = ma.fields.Integer
        self.List = ma.fields.List
        self.Mapping = ma.fields.Mapping
        self.Method = ma.fields.Method
        self.Nested = ma.fields.Nested
        self.Number = ma.fields.Number
        self.Pluck = ma.fields.Pluck
        self.Raw = ma.fields.Raw
        self.Str = ma.fields.Str
        self.String = ma.fields.String
        self.Time = ma.fields.Time
        self.TimeDelta = ma.fields.TimeDelta
        self.Tuple = ma.fields.Tuple
        self.UUID = ma.fields.UUID
        self.Url = ma.fields.Url
        self.URL = ma.fields.URL

        # alias flask_marshmallow fields
        self.AbsoluteUrlFor = flask_ma.fields.AbsoluteUrlFor
        self.AbsoluteURLFor = flask_ma.fields.AbsoluteURLFor
        self.UrlFor = flask_ma.fields.UrlFor
        self.URLFor = flask_ma.fields.URLFor
        self.Hyperlinks = flask_ma.fields.Hyperlinks
        self.HyperlinkRelated = HyperlinkRelated