Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1209 (closed defect: fixed)

Opened 11 years ago

Last modified 10 years ago

Data already flushed does not rollback if exception occurs

Reported by: sanjay Owned by: splee
Priority: high Milestone: 1.0b3
Component: TurboGears Version: 1.0b2
Severity: normal Keywords:
Cc:

Description

Summary

If we use multiple flushes (SQLAlchemy) sequentially in a controller method, and some exception occurs in between, all the flushed data should ideally rollback. It's because the controller method is automatically encapsulated in a transaction by TurboGears.

But it is not happening in the sample project attached.

Description about the attached sample project:

Models: Website, Page

Business rules:

  1. An website can consist of multiple pages.
  2. An website has a home page.
  3. Whenever a website is created, a homepage is created as well.

Url for creating an website (problem is shown here):  http://localhost:8080/tran

Attachments

demotran.tar.gz Download (86.6 KB) - added by sanjay 11 years ago.

Change History

Changed 11 years ago by sanjay

comment:1 Changed 11 years ago by fumanchu@…

Sounds to me like what you really need is a way to INSERT that's separate from the flush method (rather than changing how flush operates). This is how Dejavu works: the Sandbox.memorize method does an INSERT, and can be called repeatedly within a transaction. The Sandbox.flush_all method then executes COMMIT. (A Dejavu Sandbox is similar to an SQLAlchemy Session/Unit? of Work.)

comment:2 Changed 11 years ago by sanjay

Sounds to me like what you really need is a way to INSERT that's separate from the flush method

(rather than changing how flush operates). This is how Dejavu works: the Sandbox.memorize method

does an INSERT, and can be called repeatedly within a transaction. The Sandbox.flush_all method

then executes COMMIT. (A Dejavu Sandbox is similar to an SQLAlchemy Session/Unit? of Work.)

Sqlalchemy's flush method does NOT commit inside a transaction. It only inserts. I have tested it. I don't know why inside a turbogears automatic transaction this fails.

comment:3 Changed 10 years ago by alberto

  • Priority changed from normal to high
  • Status changed from new to assigned
  • Owner changed from anonymous to alberto

comment:4 Changed 10 years ago by splee

  • Status changed from assigned to new
  • Owner changed from alberto to splee

comment:5 Changed 10 years ago by splee

  • Status changed from new to assigned

comment:6 Changed 10 years ago by splee

  • Status changed from assigned to closed
  • Resolution set to fixed

Fixed by r2322

Note: See TracTickets for help on using tickets.