There is a web application that is implemented on Flask . The question is this. The idea is this - two different users download for example lists of goods. After that, user A changes the product, and user B also changes the same product. The system must determine that the item has already been changed and the second user overwrites the information entered first. It may look like a message to user B in which it is written that he is overwriting. The system itself works with the application database using SQLAlchemy . Flask itself, by default, processes requests sequentially, so the question of what needs to be done to implement the message sent to user B. I have been searching the Internet for a day, I don’t see anything interesting.
|
2 answers
Optimistic locking will save the father of Russian democracy. This is the simplest solution that requires minor modifications:
- Add a field to the model that stores the version of the data;
- Add exception handling
StaleDataErrorto the handler that saves the item; - Add a template with a form to resolve the conflict.
|
Real-time messaging or sending a message to the user about a change can be implemented using SocketIO - https://github.com/miguelgrinberg/python-socketio
There is an integration with Flask
|