okay, i will look at that, but back to the json=1 result.
Benjamin Kampmann
@gnunicorn
yes. so.
common/paging_schema.py is invoked
a schema is the marshmallow description to build the json
which wraps around the schemas/object schema.
Ethan Miller
@ezmiller
okay
Benjamin Kampmann
@gnunicorn
there is a lot of magic in there and I won’t go there – with meta classes and stuff. – the important part is, that in order to have a some data dumped for an object you have, you need to let the marshmallow-er know which schema to use
we have a morphing_schema for that.
Ethan Miller
@ezmiller
just looking at that
one sec
_
polymorphic_identity is this key defining what kind of object is in the row in the objects table or whatever it’s called right?
Benjamin Kampmann
@gnunicorn
to register the schema you want to have the let the ObjectField registry know about thaat.
exactly.
Ethan Miller
@ezmiller
it maps to “type” later?
Benjamin Kampmann
@gnunicorn
so. as an example, take a look at beavy_modules/private_message/schemas.py
Ethan Miller
@ezmiller
okay one sec
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.