We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
HTTP 500 while fetching the permission endpoint using the account plugin.
Error while fetching the permissions endpoint using the account plugin.

```
  File "~/kinto/venv/lib/python3.6/site-packages/cornice/service.py", line 491, in wrapper
    response = view_()
  File "~/kinto/venv/lib/python3.6/site-packages/kinto/core/resource/__init__.py", line 290, in collection_get
    include_deleted=include_deleted)
  File "~/kinto/venv/lib/python3.6/site-packages/kinto/views/permissions.py", line 84, in get_records
    from_settings = allowed_from_settings(self.request.registry.settings, principals)
  File "~/kinto/venv/lib/python3.6/site-packages/kinto/views/permissions.py", line 46, in allowed_from_settings
    'record': 'collection'}[resource_name]
KeyError: 'account'
```
HTTP 500 while fetching the permission endpoint using the account plugin.
Error while fetching the permissions endpoint using the account plugin.

```
  File "~/kinto/venv/lib/python3.6/site-packages/cornice/service.py", line 491, in wrapper
    response = view_()
  File "~/kinto/venv/lib/python3.6/site-packages/kinto/core/resource/__init__.py", line 290, in collection_get
    include_deleted=include_deleted)
  File "~/kinto/venv/lib/python3.6/site-packages/kinto/views/permissions.py", line 84, in get_records
    from_settings = allowed_from_settings(self.request.registry.settings, principals)
  File "~/kinto/venv/lib/python3.6/site-packages/kinto/views/permissions.py", line 46, in allowed_from_settings
    'record': 'collection'}[resource_name]
KeyError: 'account'
```

--- 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/permissions.py`
Content:
```
1 import colander
2 from pyramid.security import NO_PERMISSION_REQUIRED
3 from pyramid.settings import aslist
4 
5 from kinto.authorization import PERMISSIONS_INHERITANCE_TREE
6 from kinto.core import utils as core_utils, resource
7 from kinto.core.storage import Sort
8 from kinto.core.storage.memory import extract_record_set
9 
10 
11 def allowed_from_settings(settings, principals):
12     """Returns every permissions allowed from settings for the current user.
13     :param settings dict: app settings
14     :param principals list: list of principals of current user
15     :rtype: dict
16 
17     Result example::
18 
19         {
20             "bucket": {"write", "collection:create"},
21             "collection": {"read"}
22         }
23 
24     XXX: This helper will be useful for Kinto/kinto#894
25     """
26     perms_settings = {k: aslist(v) for k, v in settings.items()
27                       if k.endswith('_principals')}
28     from_settings = {}
29     for key, allowed_principals in perms_settings.items():
30         resource_name, permission, _ = key.split('_')
31         # Keep the known permissions only.
32         if resource_name not in PERMISSIONS_INHERITANCE_TREE.keys():
33             continue
34         # Keep the permissions of the current user only.
35         if not bool(set(principals) & set(allowed_principals)):
36             continue
37         # ``collection_create_principals`` means ``collection:create`` in bucket.
38         if permission == 'create':
39             permission = '{resource_name}:{permission}'.format(
40                 resource_name=resource_name,
41                 permission=permission)
42             resource_name = {  # resource parents.
43                 'bucket': '',
44                 'collection': 'bucket',
45                 'group': 'bucket',
46                 'record': 'collection'}[resource_name]
47         # Store them in a convenient way.
48         from_settings.setdefault(resource_name, set()).add(permission)
49     return from_settings
50 
51 
52 class PermissionsModel:
53     id_field = 'id'
54     modified_field = 'last_modified'
55     deleted_field = 'deleted'
56 
57     def __init__(self, request):
58         self.request = request
59 
60     def timestamp(self, parent_id=None):
61         return 0
62 
63     def get_records(self, filters=None, sorting=None, pagination_rules=None,
64                     limit=None, include_deleted=False, parent_id=None):
65         # Invert the permissions inheritance tree.
66         perms_descending_tree = {}
67         for on_resource, tree in PERMISSIONS_INHERITANCE_TREE.items():
68             for obtained_perm, obtained_from in tree.items():
69                 for from_resource, perms in obtained_from.items():
70                     for perm in perms:
71                         perms_descending_tree.setdefault(from_resource, {})\
72                                              .setdefault(perm, {})\
73                                              .setdefault(on_resource, set())\
74                                              .add(obtained_perm)
75 
76         # Obtain current principals.
77         principals = self.request.prefixed_principals
78 
79         # Query every possible permission of the current user from backend.
80         backend = self.request.registry.permission
81         perms_by_object_uri = backend.get_accessible_objects(principals)
82 
83         # Check settings for every allowed resources.
84         from_settings = allowed_from_settings(self.request.registry.settings, principals)
85 
86         # Expand permissions obtained from backend with the object URIs that
87         # correspond to permissions allowed from settings.
88         allowed_resources = {'bucket', 'collection', 'group'} & set(from_settings.keys())
89         if allowed_resources:
90             storage = self.request.registry.storage
91             every_bucket, _ = storage.get_all(parent_id='', collection_id='bucket')
92             for bucket in every_bucket:
93                 bucket_uri = '/buckets/{id}'.format_map(bucket)
94                 for res in allowed_resources:
95                     resource_perms = from_settings[res]
96                     # Bucket is always fetched.
97                     if res == 'bucket':
98                         perms_by_object_uri.setdefault(bucket_uri, set()).update(resource_perms)
99                         continue
100                     # Fetch bucket collections and groups.
101                     # XXX: wrong approach: query in a loop!
102                     every_subobjects, _ = storage.get_all(parent_id=bucket_uri,
103                                                           collection_id=res)
104                     for subobject in every_subobjects:
105                         subobj_uri = bucket_uri + '/{0}s/{1}'.format(res, subobject['id'])
106                         perms_by_object_uri.setdefault(subobj_uri, set()).update(resource_perms)
107 
108         entries = []
109         for object_uri, perms in perms_by_object_uri.items():
110             try:
111                 # Obtain associated res from object URI
112                 resource_name, matchdict = core_utils.view_lookup(self.request,
113                                                                   object_uri)
114             except ValueError:
115                 # Skip permissions entries that are not linked to an object URI
116                 continue
117 
118             # For consistency with event payloads, prefix id with resource name
119             matchdict[resource_name + '_id'] = matchdict.get('id')
120 
121             # Expand implicit permissions using descending tree.
122             permissions = set(perms)
123             for perm in perms:
124                 obtained = perms_descending_tree[resource_name][perm]
125                 # Related to same resource only and not every sub-objects.
126                 # (e.g "bucket:write" gives "bucket:read" but not "group:read")
127                 permissions |= obtained[resource_name]
128 
129             entry = dict(uri=object_uri,
130                          resource_name=resource_name,
131                          permissions=list(permissions),
132                          **matchdict)
133             entries.append(entry)
134 
135         return extract_record_set(entries, filters=filters, sorting=sorting,
136                                   pagination_rules=pagination_rules,
137                                   limit=limit)
138 
139 
140 class PermissionsSchema(resource.ResourceSchema):
141     uri = colander.SchemaNode(colander.String())
142     resource_name = colander.SchemaNode(colander.String())
143     permissions = colander.Sequence(colander.SchemaNode(colander.String()))
144     bucket_id = colander.SchemaNode(colander.String())
145     collection_id = colander.SchemaNode(colander.String(),
146                                         missing=colander.drop)
147     group_id = colander.SchemaNode(colander.String(),
148                                    missing=colander.drop)
149     record_id = colander.SchemaNode(colander.String(),
150                                     missing=colander.drop)
151 
152     class Options:
153         preserve_unknown = False
154 
155 
156 @resource.register(name='permissions',
157                    description='List of user permissions',
158                    collection_path='/permissions',
159                    record_path=None,
160                    collection_methods=('GET',),
161                    permission=NO_PERMISSION_REQUIRED)
162 class Permissions(resource.ShareableResource):
163 
164     schema = PermissionsSchema
165 
166     def __init__(self, request, context=None):
167         super().__init__(request, context)
168         self.model = PermissionsModel(request)
169 
170     def _extract_sorting(self, limit):
171         # Permissions entries are not stored with timestamp, so do not
172         # force it.
173         result = super()._extract_sorting(limit)
174         without_last_modified = [s for s in result
175                                  if s.field != self.model.modified_field]
176         # For pagination, there must be at least one sort criteria.
177         # We use ``uri`` because its values are unique.
178         if "uri" not in [s.field for s in without_last_modified]:
179             without_last_modified.append(Sort("uri", -1))
180         return without_last_modified
181 
182     def _extract_filters(self):
183         result = super()._extract_filters()
184         without_last_modified = [s for s in result
185                                  if s.field != self.model.modified_field]
186         return without_last_modified
187
```
--- 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()

```

diff --git a/kinto/views/permissions.py b/kinto/views/permissions.py
--- a/kinto/views/permissions.py
+++ b/kinto/views/permissions.py
@@ -40,10 +40,9 @@
                 resource_name=resource_name,
                 permission=permission)
             resource_name = {  # resource parents.
-                'bucket': '',
                 'collection': 'bucket',
                 'group': 'bucket',
-                'record': 'collection'}[resource_name]
+                'record': 'collection'}.get(resource_name, '')
         # Store them in a convenient way.
         from_settings.setdefault(resource_name, set()).add(permission)
     return from_settings

{"golden_diff": "diff --git a/kinto/views/permissions.py b/kinto/views/permissions.py\n--- a/kinto/views/permissions.py\n+++ b/kinto/views/permissions.py\n@@ -40,10 +40,9 @@\n                 resource_name=resource_name,\n                 permission=permission)\n             resource_name = {  # resource parents.\n-                'bucket': '',\n                 'collection': 'bucket',\n                 'group': 'bucket',\n-                'record': 'collection'}[resource_name]\n+                'record': 'collection'}.get(resource_name, '')\n         # Store them in a convenient way.\n         from_settings.setdefault(resource_name, set()).add(permission)\n     return from_settings\n", "issue": "HTTP 500 while fetching the permission endpoint using the account plugin.\nError while fetching the permissions endpoint using the account plugin.\r\n\r\n```\r\n  File \"~/kinto/venv/lib/python3.6/site-packages/cornice/service.py\", line 491, in wrapper\r\n    response = view_()\r\n  File \"~/kinto/venv/lib/python3.6/site-packages/kinto/core/resource/__init__.py\", line 290, in collection_get\r\n    include_deleted=include_deleted)\r\n  File \"~/kinto/venv/lib/python3.6/site-packages/kinto/views/permissions.py\", line 84, in get_records\r\n    from_settings = allowed_from_settings(self.request.registry.settings, principals)\r\n  File \"~/kinto/venv/lib/python3.6/site-packages/kinto/views/permissions.py\", line 46, in allowed_from_settings\r\n    'record': 'collection'}[resource_name]\r\nKeyError: 'account'\r\n```\nHTTP 500 while fetching the permission endpoint using the account plugin.\nError while fetching the permissions endpoint using the account plugin.\r\n\r\n```\r\n  File \"~/kinto/venv/lib/python3.6/site-packages/cornice/service.py\", line 491, in wrapper\r\n    response = view_()\r\n  File \"~/kinto/venv/lib/python3.6/site-packages/kinto/core/resource/__init__.py\", line 290, in collection_get\r\n    include_deleted=include_deleted)\r\n  File \"~/kinto/venv/lib/python3.6/site-packages/kinto/views/permissions.py\", line 84, in get_records\r\n    from_settings = allowed_from_settings(self.request.registry.settings, principals)\r\n  File \"~/kinto/venv/lib/python3.6/site-packages/kinto/views/permissions.py\", line 46, in allowed_from_settings\r\n    'record': 'collection'}[resource_name]\r\nKeyError: 'account'\r\n```\n", "before_files": [{"content": "import colander\nfrom pyramid.security import NO_PERMISSION_REQUIRED\nfrom pyramid.settings import aslist\n\nfrom kinto.authorization import PERMISSIONS_INHERITANCE_TREE\nfrom kinto.core import utils as core_utils, resource\nfrom kinto.core.storage import Sort\nfrom kinto.core.storage.memory import extract_record_set\n\n\ndef allowed_from_settings(settings, principals):\n    \"\"\"Returns every permissions allowed from settings for the current user.\n    :param settings dict: app settings\n    :param principals list: list of principals of current user\n    :rtype: dict\n\n    Result example::\n\n        {\n            \"bucket\": {\"write\", \"collection:create\"},\n            \"collection\": {\"read\"}\n        }\n\n    XXX: This helper will be useful for Kinto/kinto#894\n    \"\"\"\n    perms_settings = {k: aslist(v) for k, v in settings.items()\n                      if k.endswith('_principals')}\n    from_settings = {}\n    for key, allowed_principals in perms_settings.items():\n        resource_name, permission, _ = key.split('_')\n        # Keep the known permissions only.\n        if resource_name not in PERMISSIONS_INHERITANCE_TREE.keys():\n            continue\n        # Keep the permissions of the current user only.\n        if not bool(set(principals) & set(allowed_principals)):\n            continue\n        # ``collection_create_principals`` means ``collection:create`` in bucket.\n        if permission == 'create':\n            permission = '{resource_name}:{permission}'.format(\n                resource_name=resource_name,\n                permission=permission)\n            resource_name = {  # resource parents.\n                'bucket': '',\n                'collection': 'bucket',\n                'group': 'bucket',\n                'record': 'collection'}[resource_name]\n        # Store them in a convenient way.\n        from_settings.setdefault(resource_name, set()).add(permission)\n    return from_settings\n\n\nclass PermissionsModel:\n    id_field = 'id'\n    modified_field = 'last_modified'\n    deleted_field = 'deleted'\n\n    def __init__(self, request):\n        self.request = request\n\n    def timestamp(self, parent_id=None):\n        return 0\n\n    def get_records(self, filters=None, sorting=None, pagination_rules=None,\n                    limit=None, include_deleted=False, parent_id=None):\n        # Invert the permissions inheritance tree.\n        perms_descending_tree = {}\n        for on_resource, tree in PERMISSIONS_INHERITANCE_TREE.items():\n            for obtained_perm, obtained_from in tree.items():\n                for from_resource, perms in obtained_from.items():\n                    for perm in perms:\n                        perms_descending_tree.setdefault(from_resource, {})\\\n                                             .setdefault(perm, {})\\\n                                             .setdefault(on_resource, set())\\\n                                             .add(obtained_perm)\n\n        # Obtain current principals.\n        principals = self.request.prefixed_principals\n\n        # Query every possible permission of the current user from backend.\n        backend = self.request.registry.permission\n        perms_by_object_uri = backend.get_accessible_objects(principals)\n\n        # Check settings for every allowed resources.\n        from_settings = allowed_from_settings(self.request.registry.settings, principals)\n\n        # Expand permissions obtained from backend with the object URIs that\n        # correspond to permissions allowed from settings.\n        allowed_resources = {'bucket', 'collection', 'group'} & set(from_settings.keys())\n        if allowed_resources:\n            storage = self.request.registry.storage\n            every_bucket, _ = storage.get_all(parent_id='', collection_id='bucket')\n            for bucket in every_bucket:\n                bucket_uri = '/buckets/{id}'.format_map(bucket)\n                for res in allowed_resources:\n                    resource_perms = from_settings[res]\n                    # Bucket is always fetched.\n                    if res == 'bucket':\n                        perms_by_object_uri.setdefault(bucket_uri, set()).update(resource_perms)\n                        continue\n                    # Fetch bucket collections and groups.\n                    # XXX: wrong approach: query in a loop!\n                    every_subobjects, _ = storage.get_all(parent_id=bucket_uri,\n                                                          collection_id=res)\n                    for subobject in every_subobjects:\n                        subobj_uri = bucket_uri + '/{0}s/{1}'.format(res, subobject['id'])\n                        perms_by_object_uri.setdefault(subobj_uri, set()).update(resource_perms)\n\n        entries = []\n        for object_uri, perms in perms_by_object_uri.items():\n            try:\n                # Obtain associated res from object URI\n                resource_name, matchdict = core_utils.view_lookup(self.request,\n                                                                  object_uri)\n            except ValueError:\n                # Skip permissions entries that are not linked to an object URI\n                continue\n\n            # For consistency with event payloads, prefix id with resource name\n            matchdict[resource_name + '_id'] = matchdict.get('id')\n\n            # Expand implicit permissions using descending tree.\n            permissions = set(perms)\n            for perm in perms:\n                obtained = perms_descending_tree[resource_name][perm]\n                # Related to same resource only and not every sub-objects.\n                # (e.g \"bucket:write\" gives \"bucket:read\" but not \"group:read\")\n                permissions |= obtained[resource_name]\n\n            entry = dict(uri=object_uri,\n                         resource_name=resource_name,\n                         permissions=list(permissions),\n                         **matchdict)\n            entries.append(entry)\n\n        return extract_record_set(entries, filters=filters, sorting=sorting,\n                                  pagination_rules=pagination_rules,\n                                  limit=limit)\n\n\nclass PermissionsSchema(resource.ResourceSchema):\n    uri = colander.SchemaNode(colander.String())\n    resource_name = colander.SchemaNode(colander.String())\n    permissions = colander.Sequence(colander.SchemaNode(colander.String()))\n    bucket_id = colander.SchemaNode(colander.String())\n    collection_id = colander.SchemaNode(colander.String(),\n                                        missing=colander.drop)\n    group_id = colander.SchemaNode(colander.String(),\n                                   missing=colander.drop)\n    record_id = colander.SchemaNode(colander.String(),\n                                    missing=colander.drop)\n\n    class Options:\n        preserve_unknown = False\n\n\n@resource.register(name='permissions',\n                   description='List of user permissions',\n                   collection_path='/permissions',\n                   record_path=None,\n                   collection_methods=('GET',),\n                   permission=NO_PERMISSION_REQUIRED)\nclass Permissions(resource.ShareableResource):\n\n    schema = PermissionsSchema\n\n    def __init__(self, request, context=None):\n        super().__init__(request, context)\n        self.model = PermissionsModel(request)\n\n    def _extract_sorting(self, limit):\n        # Permissions entries are not stored with timestamp, so do not\n        # force it.\n        result = super()._extract_sorting(limit)\n        without_last_modified = [s for s in result\n                                 if s.field != self.model.modified_field]\n        # For pagination, there must be at least one sort criteria.\n        # We use ``uri`` because its values are unique.\n        if \"uri\" not in [s.field for s in without_last_modified]:\n            without_last_modified.append(Sort(\"uri\", -1))\n        return without_last_modified\n\n    def _extract_filters(self):\n        result = super()._extract_filters()\n        without_last_modified = [s for s in result\n                                 if s.field != self.model.modified_field]\n        return without_last_modified\n", "path": "kinto/views/permissions.py"}], "after_files": [{"content": "import colander\nfrom pyramid.security import NO_PERMISSION_REQUIRED\nfrom pyramid.settings import aslist\n\nfrom kinto.authorization import PERMISSIONS_INHERITANCE_TREE\nfrom kinto.core import utils as core_utils, resource\nfrom kinto.core.storage import Sort\nfrom kinto.core.storage.memory import extract_record_set\n\n\ndef allowed_from_settings(settings, principals):\n    \"\"\"Returns every permissions allowed from settings for the current user.\n    :param settings dict: app settings\n    :param principals list: list of principals of current user\n    :rtype: dict\n\n    Result example::\n\n        {\n            \"bucket\": {\"write\", \"collection:create\"},\n            \"collection\": {\"read\"}\n        }\n\n    XXX: This helper will be useful for Kinto/kinto#894\n    \"\"\"\n    perms_settings = {k: aslist(v) for k, v in settings.items()\n                      if k.endswith('_principals')}\n    from_settings = {}\n    for key, allowed_principals in perms_settings.items():\n        resource_name, permission, _ = key.split('_')\n        # Keep the known permissions only.\n        if resource_name not in PERMISSIONS_INHERITANCE_TREE.keys():\n            continue\n        # Keep the permissions of the current user only.\n        if not bool(set(principals) & set(allowed_principals)):\n            continue\n        # ``collection_create_principals`` means ``collection:create`` in bucket.\n        if permission == 'create':\n            permission = '{resource_name}:{permission}'.format(\n                resource_name=resource_name,\n                permission=permission)\n            resource_name = {  # resource parents.\n                'collection': 'bucket',\n                'group': 'bucket',\n                'record': 'collection'}.get(resource_name, '')\n        # Store them in a convenient way.\n        from_settings.setdefault(resource_name, set()).add(permission)\n    return from_settings\n\n\nclass PermissionsModel:\n    id_field = 'id'\n    modified_field = 'last_modified'\n    deleted_field = 'deleted'\n\n    def __init__(self, request):\n        self.request = request\n\n    def timestamp(self, parent_id=None):\n        return 0\n\n    def get_records(self, filters=None, sorting=None, pagination_rules=None,\n                    limit=None, include_deleted=False, parent_id=None):\n        # Invert the permissions inheritance tree.\n        perms_descending_tree = {}\n        for on_resource, tree in PERMISSIONS_INHERITANCE_TREE.items():\n            for obtained_perm, obtained_from in tree.items():\n                for from_resource, perms in obtained_from.items():\n                    for perm in perms:\n                        perms_descending_tree.setdefault(from_resource, {})\\\n                                             .setdefault(perm, {})\\\n                                             .setdefault(on_resource, set())\\\n                                             .add(obtained_perm)\n\n        # Obtain current principals.\n        principals = self.request.prefixed_principals\n\n        # Query every possible permission of the current user from backend.\n        backend = self.request.registry.permission\n        perms_by_object_uri = backend.get_accessible_objects(principals)\n\n        # Check settings for every allowed resources.\n        from_settings = allowed_from_settings(self.request.registry.settings, principals)\n\n        # Expand permissions obtained from backend with the object URIs that\n        # correspond to permissions allowed from settings.\n        allowed_resources = {'bucket', 'collection', 'group'} & set(from_settings.keys())\n        if allowed_resources:\n            storage = self.request.registry.storage\n            every_bucket, _ = storage.get_all(parent_id='', collection_id='bucket')\n            for bucket in every_bucket:\n                bucket_uri = '/buckets/{id}'.format_map(bucket)\n                for res in allowed_resources:\n                    resource_perms = from_settings[res]\n                    # Bucket is always fetched.\n                    if res == 'bucket':\n                        perms_by_object_uri.setdefault(bucket_uri, set()).update(resource_perms)\n                        continue\n                    # Fetch bucket collections and groups.\n                    # XXX: wrong approach: query in a loop!\n                    every_subobjects, _ = storage.get_all(parent_id=bucket_uri,\n                                                          collection_id=res)\n                    for subobject in every_subobjects:\n                        subobj_uri = bucket_uri + '/{0}s/{1}'.format(res, subobject['id'])\n                        perms_by_object_uri.setdefault(subobj_uri, set()).update(resource_perms)\n\n        entries = []\n        for object_uri, perms in perms_by_object_uri.items():\n            try:\n                # Obtain associated res from object URI\n                resource_name, matchdict = core_utils.view_lookup(self.request,\n                                                                  object_uri)\n            except ValueError:\n                # Skip permissions entries that are not linked to an object URI\n                continue\n\n            # For consistency with event payloads, prefix id with resource name\n            matchdict[resource_name + '_id'] = matchdict.get('id')\n\n            # Expand implicit permissions using descending tree.\n            permissions = set(perms)\n            for perm in perms:\n                obtained = perms_descending_tree[resource_name][perm]\n                # Related to same resource only and not every sub-objects.\n                # (e.g \"bucket:write\" gives \"bucket:read\" but not \"group:read\")\n                permissions |= obtained[resource_name]\n\n            entry = dict(uri=object_uri,\n                         resource_name=resource_name,\n                         permissions=list(permissions),\n                         **matchdict)\n            entries.append(entry)\n\n        return extract_record_set(entries, filters=filters, sorting=sorting,\n                                  pagination_rules=pagination_rules,\n                                  limit=limit)\n\n\nclass PermissionsSchema(resource.ResourceSchema):\n    uri = colander.SchemaNode(colander.String())\n    resource_name = colander.SchemaNode(colander.String())\n    permissions = colander.Sequence(colander.SchemaNode(colander.String()))\n    bucket_id = colander.SchemaNode(colander.String())\n    collection_id = colander.SchemaNode(colander.String(),\n                                        missing=colander.drop)\n    group_id = colander.SchemaNode(colander.String(),\n                                   missing=colander.drop)\n    record_id = colander.SchemaNode(colander.String(),\n                                    missing=colander.drop)\n\n    class Options:\n        preserve_unknown = False\n\n\n@resource.register(name='permissions',\n                   description='List of user permissions',\n                   collection_path='/permissions',\n                   record_path=None,\n                   collection_methods=('GET',),\n                   permission=NO_PERMISSION_REQUIRED)\nclass Permissions(resource.ShareableResource):\n\n    schema = PermissionsSchema\n\n    def __init__(self, request, context=None):\n        super().__init__(request, context)\n        self.model = PermissionsModel(request)\n\n    def _extract_sorting(self, limit):\n        # Permissions entries are not stored with timestamp, so do not\n        # force it.\n        result = super()._extract_sorting(limit)\n        without_last_modified = [s for s in result\n                                 if s.field != self.model.modified_field]\n        # For pagination, there must be at least one sort criteria.\n        # We use ``uri`` because its values are unique.\n        if \"uri\" not in [s.field for s in without_last_modified]:\n            without_last_modified.append(Sort(\"uri\", -1))\n        return without_last_modified\n\n    def _extract_filters(self):\n        result = super()._extract_filters()\n        without_last_modified = [s for s in result\n                                 if s.field != self.model.modified_field]\n        return without_last_modified\n", "path": "kinto/views/permissions.py"}]}