Welcome to copycat
Let's see how copycat works.
What copycat is?
copycat is an implementation of object prevalence in python.
It is based on the techniques of system snapshotting and transaction journalling. In the prevalent model, the object data is kept in memory in native object format, rather than being marshalled to an RDBMS or other data storage system. A snapshot of data is regularly saved to disk, and in addition to this, all changes are serialised and a log of transactions is also stored on disk.
http://en.wikipedia.org/wiki/Object_prevalence
copycat is a persistence tool which intercepts method calls, logging them into 'actions' to restore object state by re-executing these actions.
Using copycat
Every method invocation will be logged at disk. Not what you want? If so try copy cat decorators.
copycat decorators. Read-only - @readonly - methods doesn't need to be logged on disk for example.
How about thread-safety? copycat by default, provides thread safety using a reentran-lock for every single method invocation. Two methods can't be executed at the same time. If you want to customize this behaviour, check @unlocked decorator
If you are having problems you should check out common mistakes that happen when you first start working with this style of persistence.
Check out how to use Clock to avoid date problems
Only method invocations will be intercepted.
Client and Server architecture?
1 minute tutorial
Create some domain classes
1 |
class WikiPage():
|
Using copycat
1 |
When you call copycat again, all create_page executions in some other moment, will be re-executed to restore wiki state.
1 |
output:
Home
Pywiki
Copycat
Now, you can use copycat passing object instance or class:
1 |
or
1 |