Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Distinguish before/after events #651

Merged
merged 6 commits into from
Feb 26, 2016
Merged

Distinguish before/after events #651

merged 6 commits into from
Feb 26, 2016

Conversation

leplatrem
Copy link
Contributor

(revamp of #644)

tldr: We need two kinds of events: before events to run within transaction and «rollbackable». after events to run irreversible actions (that can fail)

Feedback/Critics/Stones/Hugs/Flowers welcome!

@@ -7,17 +7,41 @@ This document describes changes between each past release.
2.16.0 (unreleased)
-------------------

**Breaking changes**

- Errors are not swallowed during execution of ``ResourceChanged`` subscribers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: are not swallowed anymore during the execution of [...]

@leplatrem leplatrem force-pushed the add-post-commits-events branch from a81abe7 to d2f32ce Compare February 17, 2016 10:36


class AfterResourceChanged(_ResourceEvent):
"""Triggered after a resource was successfully changed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a note here explaining that we can be sure it this point that the resource was really changed and commited to the database.

@almet
Copy link
Contributor

almet commented Feb 23, 2016

LGTM but lacks documentation (I see there is some in the CHANGELOG but I don't believe that's enough)

@leplatrem leplatrem force-pushed the add-post-commits-events branch from d2f32ce to d1a62f0 Compare February 26, 2016 10:26
@leplatrem
Copy link
Contributor Author

I'm puzzled :

View transactions tests pass when I run them isolated:

nosetests -s --with-mocha-reporter cliquet.tests.resource.test_events cliquet.tests.test_listeners cliquet.tests.test_views_transaction

But they don't if I run the whole test suite make test-once. The resource events are simply not triggered :(

@leplatrem
Copy link
Contributor Author

Ok, found it.

In test_permission.py we alter request.registry.settings to readonly. Settings was not a copy of DEFAULT_SETTINGS and the tests were altering the default settings!


Subscribers of this event are likely to perform database operations,
alter the server response, or cancel the transaction (by raising an HTTP
exeception for example).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exception

@Natim
Copy link
Contributor

Natim commented Feb 26, 2016

Great job r+ with nit.

@Natim Natim merged commit 8f321ad into master Feb 26, 2016
@Natim Natim deleted the add-post-commits-events branch February 26, 2016 15:18
@Natim Natim removed the in progress label Feb 26, 2016
@leplatrem leplatrem modified the milestone: 3.0.0 Feb 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants