Coder Social home page Coder Social logo

Comments (7)

hbusul avatar hbusul commented on June 12, 2024 1

@siddhantgoel thanks for reviewing and merging the changes! Now that it is merged, I'm closing the issue.

from streaming-form-data.

siddhantgoel avatar siddhantgoel commented on June 12, 2024

At the moment the parser passes everything unknown to a NullTarget() so it should definitely be possible to raise an error instead. I have the feeling though that raising an error has the potential to break existing code.

There could be the case where a form contains 5 fields and on the backend we only care about the performance for 4 fields and the fifth field is outside the scope of this library. Maybe a warnings.warn() call would be a lightweight alternative of achieving a similar thing?

from streaming-form-data.

hbusul avatar hbusul commented on June 12, 2024

I agree that it should not be the default behavior. For example in the flask-restx library there is a flag for the parser called strict and by default it is false. When you set it to true, it raises an exception when an unknown field is provided. Doing it that way would be backwards compatible as well. However I do not have any strong preference, as long as I can catch the error one way or another.

from streaming-form-data.

siddhantgoel avatar siddhantgoel commented on June 12, 2024

I do like the idea of a strict mode. Would you be up for opening a PR? I think there are very few function signatures we'd need to adjust, and then update the documentation.

from streaming-form-data.

hbusul avatar hbusul commented on June 12, 2024

Sure, then I'll try to implement it. I always wanted to test Cython as long as you review why not :D

from streaming-form-data.

siddhantgoel avatar siddhantgoel commented on June 12, 2024

Awesome! 🎉

Just something to get you started with: the streaming_form_data.parser.Parser class is the Python entry-point while the _Parser class is the one running in Cython space. There's a streaming_form_data._parser._Parser._part_for method that is called to get the current Part (basically the current chunk of input being uploaded) while the parsing is being done to feed it some bytes. Inside the parsing loop there's a part = self._part_for(name) or self.default_part check so that's probably where you would need to return an error.

Let me know if there's anything I can help with and looking forward to seeing that PR!

from streaming-form-data.

hbusul avatar hbusul commented on June 12, 2024

Thanks a lot, I will look into those!

from streaming-form-data.

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.