Skip to content

Commit

Permalink
Merge pull request Kinto#729 from Kinto/prepare-3.2.4
Browse files Browse the repository at this point in the history
Prepare 3.2.4
  • Loading branch information
leplatrem authored Jul 21, 2016
2 parents b75a296 + c28b161 commit a953cea
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ Changelog

This document describes changes between each past release.

3.2.4 (unreleased)
3.2.4 (2016-07-21)
==================

- Nothing changed yet.
**Bug fixes**

- Fix bug where the resource events of a request targetting two groups/collection
from different buckets would be grouped together.


3.2.3 (2016-07-18)
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
# The short X.Y version.
version = '3.2'
# The full version, including alpha/beta/rc tags.
release = '3.2.2'
release = '3.2.4'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down
7 changes: 4 additions & 3 deletions kinto/core/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def get_resource_events(request, after_commit=False):
return events


def notify_resource_event(request, timestamp, data, action, old=None):
def notify_resource_event(request, parent_id, timestamp, data, action,
old=None):
"""
Request helper to stack a resource event.
Expand All @@ -156,8 +157,8 @@ def notify_resource_event(request, timestamp, data, action, old=None):
events = request.bound_data.setdefault("resource_events", OrderedDict())
resource_name = request.current_resource_name

# Add to impacted records or create new event.
group_by = resource_name + action.value
# Group events by resource and action.
group_by = resource_name + parent_id + action.value

if group_by in events:
already_impacted = events[group_by][2]
Expand Down
4 changes: 3 additions & 1 deletion kinto/core/resource/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,9 @@ def postprocess(self, result, action=ACTIONS.READ, old=None):
'data': result
}

self.request.notify_resource_event(timestamp=self.timestamp,
parent_id = self.get_parent_id(self.request)
self.request.notify_resource_event(parent_id=parent_id,
timestamp=self.timestamp,
data=result,
action=action,
old=old)
Expand Down
19 changes: 19 additions & 0 deletions kinto/tests/core/resource/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,25 @@ def test_one_event_is_sent_per_resource(self):
self.app.post_json("/batch", body, headers=self.headers)
self.assertEqual(len(self.events), 2)

def test_one_event_is_sent_per_parent_id(self):
# /mushrooms is a UserResource (see testapp.views), which means
# that parent_id depends on the authenticated user.
body = {
"defaults": {
"path": '/mushrooms',
"method": "POST",
"body": self.body
},
"requests": [
{"headers": {"Authorization": "Basic bWF0OjE="}},
{"headers": {"Authorization": "Basic dG90bzp0dXR1"}},
{"headers": {"Authorization": "Basic bWF0OjE="}},
]
}
self.app.post_json("/batch", body, headers=self.headers)
# Two different auth headers, thus two different parent_id:
self.assertEqual(len(self.events), 2)

def test_one_event_is_sent_per_action(self):
body = {
"defaults": {
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def read_file(filename):


setup(name='kinto',
version='3.2.4.dev0',
version='3.2.4',
description='Kinto Web Service - Store, Sync, Share, and Self-Host.',
long_description=README + "\n\n" + CHANGELOG + "\n\n" + CONTRIBUTORS,
license='Apache License (2.0)',
Expand Down

0 comments on commit a953cea

Please sign in to comment.