Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Benjamin Kampmann
@gnunicorn
I only remember fixing it for tech talks, but not yet on master.
Ethan Miller
@ezmiller
oh no
Benjamin Kampmann
@gnunicorn
need to move them to the new dokku anyways, though.
Ethan Miller
@ezmiller
i was thinking of something else
Benjamin Kampmann
@gnunicorn
let’s focus on the json api for now.
Ethan Miller
@ezmiller
Okay,
Benjamin Kampmann
@gnunicorn
that thing is trivial to fix and I will do it one day soon ;)
Ethan Miller
@ezmiller
a couple of questions
Benjamin Kampmann
@gnunicorn
shoot.
Ethan Miller
@ezmiller
1) You said that by registering the type with the ObjectField regsitry, then the morphing_schema knows how to use it…
use that schema
i.e. it knows which schema to morph?
(haha)
Benjamin Kampmann
@gnunicorn
yes.
morph is a little misleading as a name here, it is executing it as a “subschema” essentially, returning the result as if it was its own.
Ethan Miller
@ezmiller
And by morphing here we mean, wrap it in the jsonapi format that we need?
More of a WrapperSchema?
Benjamin Kampmann
@gnunicorn
no, the specific JSON-API stuff is done automagically because of using the Marshalling-thingy
Ethan Miller
@ezmiller
okay
Benjamin Kampmann
@gnunicorn
yeah, you could say that.
Ethan Miller
@ezmiller
So waht is the MorphingSchemas doing?
Benjamin Kampmann
@gnunicorn
I used “morphing” to stay in the naming of the database models – which are kinda morphing.
It is doing that lookup. allowing us to define a list of “MorphingSchema”-Objects, containing all types of morphed-object-types and render them as one list.
Ethan Miller
@ezmiller
Oh I think I’m starting to see.
Benjamin Kampmann
@gnunicorn
but the list doesn’t have to care about that. the morphing-schema is executed per item and does the lookup for it.
Ethan Miller
@ezmiller
So say for links
Or well private_messages
The schema for private_messages defines the fields and their structure in each private_message
Benjamin Kampmann
@gnunicorn
yep
Ethan Miller
@ezmiller
The morphing schema is then actually fetching the data?
i might need to study that code in MorphingSchema
Benjamin Kampmann
@gnunicorn
the data is already fetched. that is happening in the paginator.
Ethan Miller
@ezmiller
right
Benjamin Kampmann
@gnunicorn
the schema basically is given the list of objects and is asked to render them.
Ethan Miller
@ezmiller
like query.all() sort of == query.pagination() except or the inclusion of a limited set and teh Meta pagaination data?
Benjamin Kampmann
@gnunicorn
yes
Ethan Miller
@ezmiller
okay data comes into PrivateMessage schema
PrivateMessage schema renders it
then that goes through MorphingSchema that has this pre_dump decorated set of methods
Benjamin Kampmann
@gnunicorn
that return value is gathered by the PagingSchema and all of them put together into the data=[]-list
Ethan Miller
@ezmiller
oh no ony the first one there is decorated
Benjamin Kampmann
@gnunicorn
yes. that is to select which sub-schema to use.
that happens before starting to dump
Ethan Miller
@ezmiller
Okay
Benjamin Kampmann
@gnunicorn
and essentially makes it “morph” into the target schema
(actually it returns a new schema, which the surrounding code understands as “please use this schema instead”)
Ethan Miller
@ezmiller
So it’s query.pagination() -> PaginationSChema -> MorphingSchema -> (target schema) PrivateMessageSchema?
Benjamin Kampmann
@gnunicorn
these are mostly lib specific things though. marshallow kinda forces us to do that way, if we want to use. we could also do the JSON dumping differently, use different APIs or do it by hand. The nice thing about schemas is, that it is very explicit what will be rendered and how and you can even use those to “validate” incoming data...
(not that we are doing that at the moment)
yes