Closed dpwrussell closed 8 years ago
I think excluding everything but the id
on Score
is probably the best you can do. If you add the exclusion directly to the Score
object, though, you have the issue you've described. You can, however, pass exclusion information to SQLAlchemySchemaNode()
if you call it manually and then restrict the exclusion to just when you want the schema for Person
. I'm not exactly sure how you exclude child elements, though (or even if it's possible). Perhaps it's possible with the overrides
argument.
The other possibility is to just manually edit the schema afterwards. You can replace the scores
node with a SequenceSchema and then get exactly what you'd like. The objectify()
and dictify()
methods in ColanderAlchemy won't work any more, though.
Thanks, I think that answers this.
Which solution did you use?
@tisdall I actually switched to using MarshmallowSqlalchemy as (a couple of bugs aside that I've now fixed and contributed) that more closely met my requirements.
Thanks
@dpwrussell - Marshmallow looks pretty good. Are you using it with deform or is this unrelated to html forms?
@tisdall It is not related to deform at this time, but we may need that later. Right now I just want a way of validating data before submitting it to our database. This also is likely to output a reasonable targeted error message when the data is not valid, helping our data curator streamline his process.
Hi,
I am attempting to serialize an object that has a
backref
to a list (potentially zero, one or many).This will serialize
Person
like so:I've tried to find a way to change this serialization to something like this:
I don't seem to be able to. It doesn't seem to be possible to change the
typ
of a relationship with theinfo
dictionary.Obviously it is possible to add this:
to reduce the serialization of person to this:
which is a bit better, but not great. However, when I then want to serialize score specifically, it does not include those excluded fields either.
I have create a working example in this gist: https://gist.github.com/dpwrussell/7a72fee067a40f4dca97
Is this impossible?
Cheers