← Back to team overview

divmod-users team mailing list archive

Re: Axiom change logging

 

On Sun, Nov 4, 2012 at 7:49 PM, Laurens Van Houtven <_@xxxxxx> wrote:
> I currently have some tooling + a decorator that logs when an item is first
> created (more technically correct: first added to a store) by using the
> activate callback.

Did you mean the "stored" callback? "activate" is invoked every time
the item is loaded from the database.

> I would also like to log *changes* for some stuff. I'm not entirely sure yet
> if this is even a solvable problem (for example, what happens across schema
> changes?), or which

The "committed" callback is invoked when a transaction is committed in
which the item was modified; unfortunately you no longer have access
to the old data by the time that callback runs. Also, any attempt to
modify the database from the committed callback will cause the
transaction to roll back, so you'd need to do that asynchronously.

I think as far as schema upgrades go, the new version of the item will
have stored() invoked on it as if it were a completely new item, but I
haven't tested this, or even looked at the code.

Also...

> s = Shield(store=myStore, value=1)
> s.value = 10
> s.value = 5

I assume you actually meant something like:

###
s = Shield(store=myStore, value=1)

def _t1():
    s.value = 10

def _t2():
    s.value = 5

myStore.transact(_t1)
myStore.transact(_t2)
###
-- 
mithrandi, i Ainil en-Balandor, a faer Ambar


Follow ups

References