We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Blacklisting project does not purge the cache


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `warehouse/admin/utils.py`
Content:
```
1 # Licensed under the Apache License, Version 2.0 (the "License");
2 # you may not use this file except in compliance with the License.
3 # You may obtain a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
12 
13 from packaging.utils import canonicalize_name
14 from pyramid.httpexceptions import HTTPSeeOther
15 
16 from warehouse.packaging.models import (
17     Project, Release, Dependency, File, Role, JournalEntry, release_classifiers
18 )
19 
20 
21 def confirm_project(project, request):
22     confirm = request.POST.get("confirm")
23     project_name = project.normalized_name
24     if not confirm:
25         request.session.flash(
26             "Must confirm the request.",
27             queue="error",
28         )
29         raise HTTPSeeOther(
30             request.route_path(
31                 'admin.project.detail',
32                 project_name=project_name
33             )
34         )
35     if canonicalize_name(confirm) != project.normalized_name:
36         request.session.flash(
37             f"{confirm!r} is not the same as {project.normalized_name!r}",
38             queue="error",
39         )
40         raise HTTPSeeOther(
41             request.route_path(
42                 'admin.project.detail',
43                 project_name=project_name
44             )
45         )
46 
47 
48 def remove_project(project, request):
49     # TODO: We don't actually delete files from the data store. We should add
50     #       some kind of garbage collection at some point.
51 
52     request.db.add(
53         JournalEntry(
54             name=project.name,
55             action="remove",
56             submitted_by=request.user,
57             submitted_from=request.remote_addr,
58         )
59     )
60     request.db.query(Role).filter(Role.project == project).delete()
61     request.db.query(File).filter(File.name == project.name).delete()
62     (request.db.query(Dependency).filter(Dependency.name == project.name)
63                .delete())
64     (request.db.execute(release_classifiers.delete()
65                         .where(release_classifiers.c.name ==
66                                project.name)))
67     request.db.query(Release).filter(Release.name == project.name).delete()
68     request.db.query(Project).filter(Project.name == project.name).delete()
69 
70     request.session.flash(
71         f"Successfully deleted the project {project.name!r}.",
72         queue="success",
73     )
74
```
--- 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/warehouse/admin/utils.py b/warehouse/admin/utils.py
--- a/warehouse/admin/utils.py
+++ b/warehouse/admin/utils.py
@@ -64,8 +64,22 @@
     (request.db.execute(release_classifiers.delete()
                         .where(release_classifiers.c.name ==
                                project.name)))
-    request.db.query(Release).filter(Release.name == project.name).delete()
-    request.db.query(Project).filter(Project.name == project.name).delete()
+
+    # Load the following objects into the session and individually delete them
+    # so they are included in `session.deleted` and their cache keys are purged
+
+    # Delete releases first, otherwise they will get cascade-deleted by the
+    # project deletion and won't be purged
+    for release in (
+            request.db.query(Release)
+            .filter(Release.name == project.name)
+            .all()):
+        request.db.delete(release)
+
+    # Finally, delete the project
+    request.db.delete(
+        request.db.query(Project).filter(Project.name == project.name).one()
+    )
 
     request.session.flash(
         f"Successfully deleted the project {project.name!r}.",

{"golden_diff": "diff --git a/warehouse/admin/utils.py b/warehouse/admin/utils.py\n--- a/warehouse/admin/utils.py\n+++ b/warehouse/admin/utils.py\n@@ -64,8 +64,22 @@\n     (request.db.execute(release_classifiers.delete()\n                         .where(release_classifiers.c.name ==\n                                project.name)))\n-    request.db.query(Release).filter(Release.name == project.name).delete()\n-    request.db.query(Project).filter(Project.name == project.name).delete()\n+\n+    # Load the following objects into the session and individually delete them\n+    # so they are included in `session.deleted` and their cache keys are purged\n+\n+    # Delete releases first, otherwise they will get cascade-deleted by the\n+    # project deletion and won't be purged\n+    for release in (\n+            request.db.query(Release)\n+            .filter(Release.name == project.name)\n+            .all()):\n+        request.db.delete(release)\n+\n+    # Finally, delete the project\n+    request.db.delete(\n+        request.db.query(Project).filter(Project.name == project.name).one()\n+    )\n \n     request.session.flash(\n         f\"Successfully deleted the project {project.name!r}.\",\n", "issue": "Blacklisting project does not purge the cache\n\n", "before_files": [{"content": "# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom packaging.utils import canonicalize_name\nfrom pyramid.httpexceptions import HTTPSeeOther\n\nfrom warehouse.packaging.models import (\n    Project, Release, Dependency, File, Role, JournalEntry, release_classifiers\n)\n\n\ndef confirm_project(project, request):\n    confirm = request.POST.get(\"confirm\")\n    project_name = project.normalized_name\n    if not confirm:\n        request.session.flash(\n            \"Must confirm the request.\",\n            queue=\"error\",\n        )\n        raise HTTPSeeOther(\n            request.route_path(\n                'admin.project.detail',\n                project_name=project_name\n            )\n        )\n    if canonicalize_name(confirm) != project.normalized_name:\n        request.session.flash(\n            f\"{confirm!r} is not the same as {project.normalized_name!r}\",\n            queue=\"error\",\n        )\n        raise HTTPSeeOther(\n            request.route_path(\n                'admin.project.detail',\n                project_name=project_name\n            )\n        )\n\n\ndef remove_project(project, request):\n    # TODO: We don't actually delete files from the data store. We should add\n    #       some kind of garbage collection at some point.\n\n    request.db.add(\n        JournalEntry(\n            name=project.name,\n            action=\"remove\",\n            submitted_by=request.user,\n            submitted_from=request.remote_addr,\n        )\n    )\n    request.db.query(Role).filter(Role.project == project).delete()\n    request.db.query(File).filter(File.name == project.name).delete()\n    (request.db.query(Dependency).filter(Dependency.name == project.name)\n               .delete())\n    (request.db.execute(release_classifiers.delete()\n                        .where(release_classifiers.c.name ==\n                               project.name)))\n    request.db.query(Release).filter(Release.name == project.name).delete()\n    request.db.query(Project).filter(Project.name == project.name).delete()\n\n    request.session.flash(\n        f\"Successfully deleted the project {project.name!r}.\",\n        queue=\"success\",\n    )\n", "path": "warehouse/admin/utils.py"}], "after_files": [{"content": "# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom packaging.utils import canonicalize_name\nfrom pyramid.httpexceptions import HTTPSeeOther\n\nfrom warehouse.packaging.models import (\n    Project, Release, Dependency, File, Role, JournalEntry, release_classifiers\n)\n\n\ndef confirm_project(project, request):\n    confirm = request.POST.get(\"confirm\")\n    project_name = project.normalized_name\n    if not confirm:\n        request.session.flash(\n            \"Must confirm the request.\",\n            queue=\"error\",\n        )\n        raise HTTPSeeOther(\n            request.route_path(\n                'admin.project.detail',\n                project_name=project_name\n            )\n        )\n    if canonicalize_name(confirm) != project.normalized_name:\n        request.session.flash(\n            f\"{confirm!r} is not the same as {project.normalized_name!r}\",\n            queue=\"error\",\n        )\n        raise HTTPSeeOther(\n            request.route_path(\n                'admin.project.detail',\n                project_name=project_name\n            )\n        )\n\n\ndef remove_project(project, request):\n    # TODO: We don't actually delete files from the data store. We should add\n    #       some kind of garbage collection at some point.\n\n    request.db.add(\n        JournalEntry(\n            name=project.name,\n            action=\"remove\",\n            submitted_by=request.user,\n            submitted_from=request.remote_addr,\n        )\n    )\n    request.db.query(Role).filter(Role.project == project).delete()\n    request.db.query(File).filter(File.name == project.name).delete()\n    (request.db.query(Dependency).filter(Dependency.name == project.name)\n               .delete())\n    (request.db.execute(release_classifiers.delete()\n                        .where(release_classifiers.c.name ==\n                               project.name)))\n\n    # Load the following objects into the session and individually delete them\n    # so they are included in `session.deleted` and their cache keys are purged\n\n    # Delete releases first, otherwise they will get cascade-deleted by the\n    # project deletion and won't be purged\n    for release in (\n            request.db.query(Release)\n            .filter(Release.name == project.name)\n            .all()):\n        request.db.delete(release)\n\n    # Finally, delete the project\n    request.db.delete(\n        request.db.query(Project).filter(Project.name == project.name).one()\n    )\n\n    request.session.flash(\n        f\"Successfully deleted the project {project.name!r}.\",\n        queue=\"success\",\n    )\n", "path": "warehouse/admin/utils.py"}]}