Reputation: 20547
I'm building my first Pyramid app (coming from Pylons) and I'm trying to figure out how to handle exceptions with pyramid_tm... For example, in Pylons I would do something like
try:
Session.add(object)
Session.commit()
except IntegrityError:
Session.rollback()
flash("Object already present")
but how is this supposed to be done with pyramid_tm?
Upvotes: 3
Views: 1271
Reputation: 1274
Use Session.flush()
instead of Session.commit()
.
With pyramid_tm, you should never (need to) do commit()
yourself in request handling code.
Upvotes: 5