Rubric: views does .save, port to select_for_update, improve wiki
In Rubrics/views.py
, there is some .save
going on, based on a QuerySet returned from a service.
- I blindly tried adding a .select_for_update and got this error:
select_for_update cannot be used outside of a transaction
- so is it even well-defined what the .save does?
- fix this.
- TODO: articulate what I don't like about this code on the wiki:
- draft: "Views should never call .save".
- draft: QuerySet that are returned outside of a service should be RO.
- draft: all RW QuerySet must be contained inside services
- exceptions are possible but must be clearly documented
- It would be nice if there was some linter or Django itself that could throw an exception if you
.save
during a non-select-for-update transaction!