| 9 | MemoRecord = namedtuple("MemoRecord", "key, task") |
| 10 | |
| 11 | class DBPickler(pickle.Pickler): |
| 12 | |
| 13 | def persistent_id(self, obj): |
| 14 | # Instead of pickling MemoRecord as a regular class instance, we emit a |
| 15 | # persistent ID. |
| 16 | if isinstance(obj, MemoRecord): |
| 17 | # Here, our persistent ID is simply a tuple, containing a tag and a |
| 18 | # key, which refers to a specific record in the database. |
| 19 | return ("MemoRecord", obj.key) |
| 20 | else: |
| 21 | # If obj does not have a persistent ID, return None. This means obj |
| 22 | # needs to be pickled as usual. |
| 23 | return None |
| 24 | |
| 25 | |
| 26 | class DBUnpickler(pickle.Unpickler): |
no outgoing calls
no test coverage detected
searching dependent graphs…