Skip to content
This repository has been archived by the owner on Sep 12, 2020. It is now read-only.

Latest commit

 

History

History
48 lines (41 loc) · 1.21 KB

HowItWorks.md

File metadata and controls

48 lines (41 loc) · 1.21 KB

load(cls, data)

  1. Checks to make sure the Schema exists for the class (i.e. add_schema decorator is added)
  2. If data is a list, then its interpreted as json_to_models
  3. json_to_model
    1. calls to_model
    2. saves raw data.
    3. Marshalling is unlocked.
    4. returns the model
  4. to_model
    1. loads the schema_opts()
    2. creates marshmallow schema using opts
    3. loads the schema using the data
    4. returns model

getting attributes

If attribute exists, __getattribute__(name) is called.

schema_class = self.Schema
x = self.name
if name is in relationship names
    if marshalling is unlocked
        r = schema.relationships[name]
        get the relationship from the schema_class
        if x is is model expected from the relationship
            return x
        else
            x = fullfill_relationship(name)
            return x if not None
else
    return x

attempts to get name (getattr runs if it cannot get it)

schema_class = self.Schema
if name is in relationship names
    v = fullfill_relationship(name)
    return v
v = object.__getattribute__(name)
return v

if name is the name found in a relationship:

If attribute does not exist, __getattr__ is called