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
there is a schema that explains the private message – and then at the end registers that with the morphing-schema. essentially saying: if you find a type=private_message use this schema.
you need to do the same for the object you have

re

it maps to “type” later?

Ethan Miller
@ezmiller
ahah
Benjamin Kampmann
@gnunicorn
Unfortunately that is kinda hard-coded inside marshmallow and not easy to get into that. so your Schema must have a class Meta, which must have a type property set properly at the moment. look at the private message as an example again.
Ethan Miller
@ezmiller
The ObjectRegistry is hard-coded?
Benjamin Kampmann
@gnunicorn
if you did both of those, and restart the server, the resulting json should contain the data you want it to dump
Ethan Miller
@ezmiller
sorry ObjectField.registry...
Benjamin Kampmann
@gnunicorn
ObjectField is just a field containing any morphing object type. the registry is just a dictionary on that class (so a singleton inside this running process) which allows it to look up which schema to actually use when it encouters a specific type.
see beavy/schemas/object ->
class ObjectField(MorphingSchema):
    FALLBACK = BaseObject
    registry = {}
Ethan Miller
@ezmiller
Just trying to parse all this. Hold on.
Benjamin Kampmann
@gnunicorn
(the travis errors are the known “enter passphrase”- problem. need to fix that one!)
sure.
gnunicorn @ligthyear will go to bed soon, but I can wait a bit ;)
Ethan Miller
@ezmiller
didn’t we have a fix for that?
Benjamin Kampmann
@gnunicorn
did we?
Ethan Miller
@ezmiller
oh
yeah
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.