GitXplorerGitXplorer
k

django-formality

public
8 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
d81c4bbc6c38921a278d242ba9ce2338de5cdae9

don't allow a single value like a[99999] to push us over our desired max fields?

kkezabelle committed 3 years ago
Unverified
88a7f1bd203d7d9c9541a5c88b93a181d500c109

first pass at re-using Django's multipart parser to handle deeply nesting key/values in boundaries.

kkezabelle committed 3 years ago
Unverified
828cd179bdb888aa4bf092edeed463c25f6a2d16

Adding the bytestrings representing FakePayloads used by Django's internal test suite when the Content-Type is `application/x-www-form-urlencoded`

kkezabelle committed 3 years ago
Unverified
bb0d0875b4ae3d43a207c5762f1c62f5df4177c4

sigh. mypy really is kinda terrible. Tidying up a few actual fixes, ignoring a whole bunch. I'd love to love mypy, but it's so poor compared to typescript :(

kkezabelle committed 3 years ago
Unverified
794294557e05f66733a569e6dcf2f5ef3056eed3

add some brief readme overviews.

kkezabelle committed 3 years ago
Unverified
36f4a4fa7df9a5ace120d6e61bcc9af14641201c

I think this now means I can do any of:

kkezabelle committed 3 years ago

README

The README file for this repository.

django-formality

:author: Keryn Knight :version: 0.1.0

If Django_ had support for parsing nested query-string and form-encoded data, and the existing Forms API supported nested data, what would that look like, and how much of a RESTy API could be built on such?

Brief

Currently, this is just a parser capable of dumping structured query-string data in the form of::

a[][item]=4&a[][item]=5&a[][item]=6

into a data-structure like::

{'a': [{'item': 4}, {'item': 5}, {'item': 6}]}

It mostly tries to conform sensibly(ish) to Rack_ and jQuery-BBQ_ (and is in fact a semi-transliteration of the latter) but skirts certain edge cases I'm not brainy enough to solve ... That basically means I'll throw an exception for "malformed" data.

Eventually, I've got plans for a bunch more. But this is absolutely currently just an experiment in how far I'll be able to take things

Goals

An optimistic list of the things I'd like this to achieve, regardless of if I currently know how. Off the top of my head:

  • Nested structure support for normal web forms & query strings, like PHP, Rack and jQuery-BBQ_ have.

    • circuit-breaking of those nested values if they surpass a given limit (following e.g. Django's DATA_UPLOAD_MAX_NUMBER_FIELDS_)
  • The ability to use the Forms API to describe nested data, for both input parsing and output.

  • Flexible parsing and content-negotiation based on those Forms.

  • OpenAPI_ generation from the very same Forms, so I can have nice Swagger UI_ or ReDoc_ output.

    • Ideally, I want the ability to do this for anything I can detect as being a form-based view.

.. _Django: https://www.djangoproject.com/ .. _jQuery-BBQ: https://benalman.com/projects/jquery-bbq-plugin/ .. _PHP: https://www.php.net/manual/en/function.parse-str.php .. _Rack: https://rack.github.io/ .. _DATA_UPLOAD_MAX_NUMBER_FIELDS: https://docs.djangoproject.com/en/4.0/ref/settings/ .. _OpenAPI: https://swagger.io/ .. _Swagger UI: https://swagger.io/tools/swagger-ui/ .. _ReDoc: https://github.com/Redocly/redoc