[Cubicweb] ValidationError and implicit rollbacks

Sylvain Thénault sylvain.thenault at logilab.fr
Thu Sep 30 16:53:02 CEST 2010

On 30 septembre 16:06, Aurélien Campeas wrote:
> Le jeudi 30 septembre 2010 à 15:57 +0200, Adrien Di Mascio a écrit :
> > Hi there,
> > 
> Hi,
> > In CW 3.9, if a ValidationError is raised, the transaction is implicitly 
> > rollbacked. As far as I understand, this is done to prevent any later 
> > commit() (in the same transaction) from letting the database in an 
> > inconsistent state.
> hmm, it used to be that the commit/rollback, from the web front pov, was
> done in application.publish (or something)
> that is quite predictable & allows various ValidationError handling from
> beneath

such as ?
> am i missing something ?

this has been introduced because currently, it may occur that a ValidationError
is raised but the value has been saved in the database. The repository should
not let a subsequent commit commiting the database with some integrity error 

We already had such behaviour in case where Unauthorized is raised. It's now
documented that it also happen on ValidationError. We also already had such
mecanism in case of error during commit.

The other possibility is to do like regular DBMS does: no rollback is done,
but the connection is left in a state where you can't do anything with it
until you rollback. I don't think that would make anything better though.

> > For the record, I've discovered this because I implemented a custom 
> > EditController that catches ValidationError and is able to treat some of 
> > them as part of the normal execution flow under certain conditions.
> > 
> > This post is here to inform some of you who, just like me, might have 
> > skipped this new "feature". I wonder however if I hadn't prefered simply
> > a non-commitable transaction (i.e. waiting for an explicit rollback()) 
> > rather than an implicit one.
> > 
> > What do you think ?
> Immediately & automatically (behind-our-back) rollbacking on
> ValidationError is wrong (I think it breaks working customer code).

such as ?

Sylvain Thénault                               LOGILAB, Paris (France)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org

More information about the Cubicweb mailing list