prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Deleting a collection doesn't delete access_control_entries for its children
  `buckets.py` has an event listener that ensures that when a bucket is deleted, everything underneath it is recursively deleted. `collections.py` has one too but it doesn't appear to be as robust -- it doesn't have a wildcard to match objects more than one level below it (which might be OK, since only records are below collections now), and `delete_object_permissions` is only called on the collection rather than its children.
  
  </issue>
  <code>
  [start of kinto/views/collections.py]
  1 import colander
  2 from pyramid.events import subscriber
  3 
  4 from kinto.core import resource, utils
  5 from kinto.core.events import ResourceChanged, ACTIONS
  6 from kinto.schema_validation import validate_from_bucket_schema_or_400, JSONSchemaMapping
  7 
  8 
  9 class CollectionSchema(resource.ResourceSchema):
  10     schema = JSONSchemaMapping(missing=colander.drop)
  11     cache_expires = colander.SchemaNode(colander.Int(), missing=colander.drop)
  12 
  13 
  14 @resource.register(name='collection',
  15                    collection_path='/buckets/{{bucket_id}}/collections',
  16                    record_path='/buckets/{{bucket_id}}/collections/{{id}}')
  17 class Collection(resource.ShareableResource):
  18     schema = CollectionSchema
  19     permissions = ('read', 'write', 'record:create')
  20 
  21     def get_parent_id(self, request):
  22         bucket_id = request.matchdict['bucket_id']
  23         parent_id = utils.instance_uri(request, 'bucket', id=bucket_id)
  24         return parent_id
  25 
  26     def process_record(self, new, old=None):
  27         """Additional collection schema validation from bucket, if any."""
  28         new = super().process_record(new, old)
  29 
  30         # Remove internal and auto-assigned fields.
  31         internal_fields = (self.model.id_field,
  32                            self.model.modified_field,
  33                            self.model.permissions_field)
  34         validate_from_bucket_schema_or_400(new, resource_name="collection", request=self.request,
  35                                            ignore_fields=internal_fields)
  36         return new
  37 
  38 
  39 @subscriber(ResourceChanged,
  40             for_resources=('collection',),
  41             for_actions=(ACTIONS.DELETE,))
  42 def on_collections_deleted(event):
  43     """Some collections were deleted, delete records.
  44     """
  45     storage = event.request.registry.storage
  46     permission = event.request.registry.permission
  47 
  48     for change in event.impacted_records:
  49         collection = change['old']
  50         bucket_id = event.payload['bucket_id']
  51         parent_id = utils.instance_uri(event.request, 'collection',
  52                                        bucket_id=bucket_id,
  53                                        id=collection['id'])
  54         storage.delete_all(collection_id=None,
  55                            parent_id=parent_id,
  56                            with_deleted=False)
  57         storage.purge_deleted(collection_id=None,
  58                               parent_id=parent_id)
  59         permission.delete_object_permissions(parent_id)
  60
  [end of kinto/views/collections.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/kinto/views/collections.py b/kinto/views/collections.py
  --- a/kinto/views/collections.py
  +++ b/kinto/views/collections.py
  @@ -56,4 +56,4 @@
                              with_deleted=False)
           storage.purge_deleted(collection_id=None,
                                 parent_id=parent_id)
  -        permission.delete_object_permissions(parent_id)
  +        permission.delete_object_permissions(parent_id + '/*')
  
verification_info: {"golden_diff": "diff --git a/kinto/views/collections.py b/kinto/views/collections.py\n--- a/kinto/views/collections.py\n+++ b/kinto/views/collections.py\n@@ -56,4 +56,4 @@\n                            with_deleted=False)\n         storage.purge_deleted(collection_id=None,\n                               parent_id=parent_id)\n-        permission.delete_object_permissions(parent_id)\n+        permission.delete_object_permissions(parent_id + '/*')\n", "issue": "Deleting a collection doesn't delete access_control_entries for its children\n`buckets.py` has an event listener that ensures that when a bucket is deleted, everything underneath it is recursively deleted. `collections.py` has one too but it doesn't appear to be as robust -- it doesn't have a wildcard to match objects more than one level below it (which might be OK, since only records are below collections now), and `delete_object_permissions` is only called on the collection rather than its children.\n", "before_files": [{"content": "import colander\nfrom pyramid.events import subscriber\n\nfrom kinto.core import resource, utils\nfrom kinto.core.events import ResourceChanged, ACTIONS\nfrom kinto.schema_validation import validate_from_bucket_schema_or_400, JSONSchemaMapping\n\n\nclass CollectionSchema(resource.ResourceSchema):\n    schema = JSONSchemaMapping(missing=colander.drop)\n    cache_expires = colander.SchemaNode(colander.Int(), missing=colander.drop)\n\n\n@resource.register(name='collection',\n                   collection_path='/buckets/{{bucket_id}}/collections',\n                   record_path='/buckets/{{bucket_id}}/collections/{{id}}')\nclass Collection(resource.ShareableResource):\n    schema = CollectionSchema\n    permissions = ('read', 'write', 'record:create')\n\n    def get_parent_id(self, request):\n        bucket_id = request.matchdict['bucket_id']\n        parent_id = utils.instance_uri(request, 'bucket', id=bucket_id)\n        return parent_id\n\n    def process_record(self, new, old=None):\n        \"\"\"Additional collection schema validation from bucket, if any.\"\"\"\n        new = super().process_record(new, old)\n\n        # Remove internal and auto-assigned fields.\n        internal_fields = (self.model.id_field,\n                           self.model.modified_field,\n                           self.model.permissions_field)\n        validate_from_bucket_schema_or_400(new, resource_name=\"collection\", request=self.request,\n                                           ignore_fields=internal_fields)\n        return new\n\n\n@subscriber(ResourceChanged,\n            for_resources=('collection',),\n            for_actions=(ACTIONS.DELETE,))\ndef on_collections_deleted(event):\n    \"\"\"Some collections were deleted, delete records.\n    \"\"\"\n    storage = event.request.registry.storage\n    permission = event.request.registry.permission\n\n    for change in event.impacted_records:\n        collection = change['old']\n        bucket_id = event.payload['bucket_id']\n        parent_id = utils.instance_uri(event.request, 'collection',\n                                       bucket_id=bucket_id,\n                                       id=collection['id'])\n        storage.delete_all(collection_id=None,\n                           parent_id=parent_id,\n                           with_deleted=False)\n        storage.purge_deleted(collection_id=None,\n                              parent_id=parent_id)\n        permission.delete_object_permissions(parent_id)\n", "path": "kinto/views/collections.py"}]}