Skip to main content
undoredo
--------

undo/redo functionality for arbitrary python classes

Supports Python 3. Might work in Python 2.

> Author: Ross Anderson ([rosshamish](https://github.com/rosshamish))

### Installation

```
pip install undoredo
```

### Usage

Any class can gain undo/redo functionality by doing the following:

- keep around an instance of UndoManager
- annotate undoable methods with the @undoable decorator
- implement do(), undo(), and redo() methods as shown in the following example
- implement copy(), and restore(obj) methods
- where copy() returns a copy of the object (probably a deep copy)
- where restore(obj) restores the calling object to the state of the passed object

### Example

```
import undoredo

class Counter(object):
def __init__(self, value=0):
self.undo_mgr = undoredo.UndoManager()
self.value = value

@undoredo.undoable
def increment(self):
self.value += 1

@undoredo.undoable
def decrement(self):
self.value -= 1

def do(self, command):
return self.undo_mgr.do(command)

def undo(self):
return self.undo_mgr.undo()

def redo(self):
return self.undo_mgr.redo()

def copy(self):
return Counter(self.value)

def restore(self, counter):
self.value = counter.value

c = Counter(0) # 0
c.increment() # 1
c.increment() # 2
c.undo() # 1
c.redo() # 2
```

### License

GPLv3

Metadata

Release files for undoredo 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for undoredo 0.1.4
File Size Uploaded Provenance
undoredo-0.1.4.tar.gz 2.5 kB Without provenance Details

Release files / undoredo-0.1.4.tar.gz

Download URL undoredo-0.1.4.tar.gz
Size 2.5 kB
Tags Source
SHA-256 checksum
How to use checksums
abc1839ebf3aab3cdd5353595ad87875fd98d3f520843326720241f022fd07f9
BLAKE2b-256 checksum
How to use checksums
13d25522e7e9ef97b4673633f960f147b1630ec50e7a88a7dbfcda8a759db68a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for undoredo 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.4 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page