Coder Social home page Coder Social logo

Comments (6)

gdiscry avatar gdiscry commented on August 19, 2024

I'm interested in this feature.

Personally, the infinite recursion problem is not an issue for my use case if we could also use hierarchical only/exclude parameters which would look like:

serialized = BookMarshal(book, only=('isbn', 'date_created', 'author.created'))

or

serialized = BookMarshal(book, exclude=('author.books',))

I use marshmallow when generating CSV files from SQLAlchemy objects with csv.DictWriter. I serialize the SQLAlchemy object with marshmallow, flatten the resulting dict (keys are joined with .) and pass that dict to csv.DictWriter. As DictWriter already requires a list of fieldnames, using the same list with the serializer would be great.

Anyway, that's another feature. The conclusion is that explicit is better than implicit.

from marshmallow.

DeaconDesperado avatar DeaconDesperado commented on August 19, 2024

👍 for proposed API, even though it's a big change. The resolution by string name is a pretty common pattern for situations like this, where it's important to make definition order have no effect on lookup.

from marshmallow.

sloria avatar sloria commented on August 19, 2024

@gdiscry I like the explicitness of your proposed hierarchical filtering.

I'm leaning towards going ahead with this. Will likely starting prototyping it for the next release.

from marshmallow.

justanr avatar justanr commented on August 19, 2024

I'm going to say that this is a big thumbs up, as well. If you're doubting on if they should be passed as strings or not, you could take a page from SQLAlchemy's book and allow a callable (such as a lambda) instead.

from marshmallow.

DigTheDoug avatar DigTheDoug commented on August 19, 2024

Glad to hear it, this is definitely a plus in my book. Using mongodb we use ReferenceFields often and being able to match that pattern when we serialize them would be great.

from marshmallow.

sloria avatar sloria commented on August 19, 2024

This has been implemented on develop. Feel free to try it out and give feedback.

pip install -U git+https://github.com/sloria/marshmallow.git@dev

from marshmallow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.