Forums

modeling sequences of actions

This is a bit of an architecture question rather than a PyAnywhere kind of question, but just in case anyone has been doing something similar and has some insights. Maybe this is a StackOverflow question but I prefer if someone answers here. Thanks.

Suppose you make an app that helps a user do a series of edits, for example, to an image. For example, you have resize, crop, apply a filter, etc.

Q: How would you typically model this behavior using a python app and mongodb, so that, at least for that session, you can keep track of the sequence of actions taken? For example you might want an undo/redo stack. Each image has an input and an output condition. At any time, the user might save the state of that image (or maybe it's auto-saved). At the end of the session, the user could save/export/etc. the image. Once the session is over, the sequence does not need to be kept.

Answering my own question after some more study.

Linear undo/redo/chronology. Just use timestamp and sort in reverse chronological order to go backward. Simple.

Non-linear where C is after A and B in a sequence (e.g., a video edit), but A feeds into C, but then B is added (e.g., adding an audio track, some other layer, etc.): not really sure. Probably have to keep track of pre, post, a timeline, coordinates in space (if a visual), etc.

Haven't decided how to do this yet.