On 03/10/2017 11:12 AM, Alessandro Molina wrote:
On Fri, Mar 10, 2017 at 3:40 PM, mike bayer <mike...@zzzcomputing.com
<mailto:mike...@zzzcomputing.com>> wrote:
If this is truly, "unexpected error but we need to do things",
perhaps you can use before_flush() to memoize the details you need
for a restore inside of session.info <http://session.info>.
An event hook can be added but it would need to be carefully
considered what the specific use case for this hook is. For
example I'm not sure "before_rollback()" is really what this should
be, it likely should be "on flush exception" similar to how engine
does it.
My specific need is related to https://github.com/amol-/depot/issues/36
DEPOT allows loading files associated to database data.
In case of a rollback DEPOT deletes the files that got uploaded.
That works in case of `.flush()` + `.rollback()` because it gathers the
history of the entity and the changed files in `before_flush`, but if a
rollback is issued without a flush it currently lacks an event from
which it can get the state of the objects and their history before the
rollback.
Looking at the code for how the events are called I would say that
moving the after_rollback() event call to be before the attributes are
reset might be more appropriate. The after_commit() event works this
way, that is, inside of after_commit() things have not yet been expired.
This would be an example of how critical it is that we consider
really deeply how these events are implemented. Throwing them in
quickly is how these design mistakes occur.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and
Verifiable Example. See http://stackoverflow.com/help/mcve for a full
description.
---
You received this message because you are subscribed to the Google
Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to sqlalchemy+unsubscr...@googlegroups.com
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.