I notice no such API events as before_expunge() or after_expunge().
Hopefully without taking much of your time, can you point me in any
direction of how I might go about being notified when an object is
expunged?

Why?

There are certain states a persistent record reaches where further
changes to it are forbidden and it becomes a "historical" record, for
example, for accounting purposes.  For example, consider a closed
order, shipped, paid for, done.  There are times, however, when I want
to re-run calculations on such objects to calculate a delta for
finances, etc.  Suppose a discount were retroactively applied to this
order, such that you want to use existing code to rerun tax
calculations, etc for the closed order and inspect all the changes
without danger of it being persisted to the database.

I am heading down the road of expunging objects that have reached this
"archived, historical" state so that I can still use the object for
all it's calculations and be assured that no changes will be persisted
to the database.  (Another thought I had was using transient objects,
but I think the end result is similar)

My concern is that once such an object has been expunged, I don't want
any relationship or code or anything automatically reloading or
refreshing it from the database with session.query().get.  My plan was
to record expunged objects on the session object so I could look them
up during reconstruct_instance() and raise an error if the same record
is being loaded from the database that I've already expunged.

Do you understand where I am headed and can you think of a better
mechanism to deal with what I'm trying to accomplish?

Thanks!
Kent

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to