prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN 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.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `kinto/views/collections.py`
  Content:
  ```
  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 FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
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"}], "after_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"}]}