PyWorkflowApp / visual-programming

A Python Visual Programming Workspace for Data Science
MIT License
33 stars 12 forks source link

Move load/save of Workflow object to Middleware #33

Closed reelmatt closed 4 years ago

reelmatt commented 4 years ago

Notes on middleware

This moves the loading

Workflow.from_session(request.session)

and saving

request.session.update(workflow.to_session_dict())

of the Workflow object to the middleware. Now, views that should have access to a Workflow object can do so by calling request.pyworkflow.method_or_attr.

The middleware has a few exceptions. Namely, it:

Other notes

This moves the retrieve_nodes_for_user route (the one that assembles the Node classes into a JSON object) from the Workflow app --> the vp app. The main reason was to prevent more special cases for the middleware to handle, but I think it also makes sense in terms of app separation. Installed nodes should belong to the 'vp' app overall, not defined in a specific workflow (although we haven't reached custom nodes yet). The front-end call was changed to hit /nodes.

These changes do not include saving the visual workflow from the front-end in the session. While it should now be an easy addition, I wanted to make sure the middleware didn't break the existing functionality before making additional changes.