Re-assess how data is sent to the back end

Open
#676 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Stale

Research direction

Start with the Front End Developer's Guide sections on Serialising Form Data and Handling User Interactions with Ajax. Search the Ajax functions, Flask receiver methods using request.form or request.json, and self._front_end_data. Done means the project has an agreed data format, defined type handling, and a clear approach for JavaScript arrays.

Written by the indexing model from the issue text.

Description

Back End enhancement obsolete v4.0?

There are several related issues here:

  1. Some Ajax functions use the HTML FormData API to serialise the data sent to the back end. In Flask, this has to be accessed using request.form. Elsewhere, we send data in the form of a JSON string, which is accessed with request.json. We should have a single format to standardise the receiver methods.
  2. A simplified receiver should annotate the type of self._front_end_data as Dict[str, str]. That means that everything in the dict extracted from the JSON string must be of type string. We need to guarantee that that is the case and remember to cast the values to integers, floats, Booleans, etc. before we use them.
  3. It is not clear what happens to Javascript array data, which deserialises as a Python list. Of the standard form input types, checkboxes are (I think) the only type that submits an array. The other scenario is if we try to send an arbitrary array to the back end via an Ajax request. How do we handle this scenario? On the front end? On the back end? (A very cursory search of Stack Overflow suggested the latter.)

Relevant reading from the Front End Developer's Guide:

Dominant language
Python
Stars
123
Forks
20
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WheatonCS/Lexos

All issues in WheatonCS/Lexos

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.