Skip to content

Commit 40bfe63

Browse files
authored
Proxito: remove old implementation (#10660)
Mostly removing old code, there is only one small custom addition https://github.com/readthedocs/readthedocs.org/blob/6595bdac198b482e1279c0e3b1925198f6baa631/readthedocs/proxito/views/serve.py#L144-L146 Django doesn't capture the first slash, previously we were getting the path from request.path_info, that includes the slash! When a request is done to `/` the path is set to "" (empty), our code relies on that being `/`. - Closes #10408 - Closes #8399 ### How to deploy this change - Deploy everything as usual, but don't run the `projects 0105` migration!!! - After deploy is done, run the `projects 0105` migration
1 parent 4be38fa commit 40bfe63

21 files changed

+189
-1298
lines changed

readthedocs/api/v2/serializers.py

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class Meta:
3030
"documentation_type",
3131
"users",
3232
"canonical_url",
33-
"urlconf",
3433
"custom_prefix",
3534
)
3635

readthedocs/core/resolver.py

-35
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def base_resolve_path(
6464
project_relationship=None,
6565
subdomain=None,
6666
cname=None,
67-
urlconf=None,
6867
custom_prefix=None,
6968
):
7069
"""
@@ -97,38 +96,6 @@ def base_resolve_path(
9796
else:
9897
path = unsafe_join_url_path(path, "{language}/{version}/{filename}")
9998

100-
# TODO: remove this when all projects have migrated to path prefixes.
101-
# Allow users to override their own URLConf
102-
# If a custom prefix is given, we don't use the custom URLConf,
103-
# since they are not compatible with each other.
104-
# We also don't check if the project has the new proxito implementation
105-
# enabled, this is so we can start generating links with the new
106-
# custom prefixes without starting to serve docs with it (this helps to ease
107-
# the migration from urlconf to custom prefixes).
108-
if urlconf and not custom_prefix:
109-
path = urlconf
110-
path = path.replace(
111-
"$version",
112-
"{version}",
113-
)
114-
path = path.replace(
115-
'$language',
116-
'{language}',
117-
)
118-
path = path.replace(
119-
'$filename',
120-
'{filename}',
121-
)
122-
path = path.replace(
123-
"$subproject",
124-
"{subproject}",
125-
)
126-
if "$" in path:
127-
log.warning(
128-
"Unconverted variable in a resolver URLConf.",
129-
path=path,
130-
)
131-
13299
subproject_alias = project_relationship.alias if project_relationship else ""
133100
return path.format(
134101
project=project_slug,
@@ -147,7 +114,6 @@ def resolve_path(
147114
single_version=None,
148115
subdomain=None,
149116
cname=None,
150-
urlconf=None,
151117
):
152118
"""Resolve a URL with a subset of fields defined."""
153119
version_slug = version_slug or project.get_default_version()
@@ -181,7 +147,6 @@ def resolve_path(
181147
project_relationship=project_relationship,
182148
cname=cname,
183149
subdomain=subdomain,
184-
urlconf=urlconf or project.urlconf,
185150
custom_prefix=custom_prefix,
186151
)
187152

readthedocs/core/unresolver.py

+2
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ def unresolve_path(self, unresolved_domain, path, append_indexhtml=True):
214214
:param append_indexhtml: If `True` directories will be normalized
215215
to end with ``/index.html``.
216216
"""
217+
# Make sure we always have a leading slash.
218+
path = self._normalize_filename(path)
217219
# We don't call unparse() on the path,
218220
# since it could be parsed as a full URL if it starts with a protocol.
219221
parsed_url = ParseResult(

readthedocs/projects/fixtures/test_data.json

-17
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"default_branch": null,
1818
"requirements_file": null,
1919
"documentation_type": "sphinx",
20-
"urlconf": null,
2120
"external_builds_enabled": false,
2221
"external_builds_privacy_level": "public",
2322
"cdn_enabled": false,
@@ -70,7 +69,6 @@
7069
"default_branch": null,
7170
"requirements_file": null,
7271
"documentation_type": "sphinx",
73-
"urlconf": null,
7472
"external_builds_enabled": false,
7573
"external_builds_privacy_level": "public",
7674
"cdn_enabled": false,
@@ -123,7 +121,6 @@
123121
"default_branch": null,
124122
"requirements_file": null,
125123
"documentation_type": "sphinx",
126-
"urlconf": null,
127124
"external_builds_enabled": false,
128125
"external_builds_privacy_level": "public",
129126
"cdn_enabled": false,
@@ -176,7 +173,6 @@
176173
"default_branch": null,
177174
"requirements_file": null,
178175
"documentation_type": "sphinx",
179-
"urlconf": null,
180176
"external_builds_enabled": false,
181177
"external_builds_privacy_level": "public",
182178
"cdn_enabled": false,
@@ -229,7 +225,6 @@
229225
"default_branch": null,
230226
"requirements_file": null,
231227
"documentation_type": "sphinx",
232-
"urlconf": null,
233228
"external_builds_enabled": false,
234229
"external_builds_privacy_level": "public",
235230
"cdn_enabled": false,
@@ -282,7 +277,6 @@
282277
"default_branch": null,
283278
"requirements_file": null,
284279
"documentation_type": "sphinx",
285-
"urlconf": null,
286280
"external_builds_enabled": false,
287281
"external_builds_privacy_level": "public",
288282
"cdn_enabled": false,
@@ -335,7 +329,6 @@
335329
"default_branch": null,
336330
"requirements_file": null,
337331
"documentation_type": "sphinx",
338-
"urlconf": null,
339332
"external_builds_enabled": false,
340333
"external_builds_privacy_level": "public",
341334
"cdn_enabled": false,
@@ -388,7 +381,6 @@
388381
"default_branch": null,
389382
"requirements_file": null,
390383
"documentation_type": "sphinx",
391-
"urlconf": null,
392384
"external_builds_enabled": false,
393385
"external_builds_privacy_level": "public",
394386
"cdn_enabled": false,
@@ -441,7 +433,6 @@
441433
"default_branch": null,
442434
"requirements_file": null,
443435
"documentation_type": "sphinx",
444-
"urlconf": null,
445436
"external_builds_enabled": false,
446437
"external_builds_privacy_level": "public",
447438
"cdn_enabled": false,
@@ -494,7 +485,6 @@
494485
"default_branch": null,
495486
"requirements_file": null,
496487
"documentation_type": "sphinx",
497-
"urlconf": null,
498488
"external_builds_enabled": false,
499489
"external_builds_privacy_level": "public",
500490
"cdn_enabled": false,
@@ -547,7 +537,6 @@
547537
"default_branch": null,
548538
"requirements_file": null,
549539
"documentation_type": "sphinx",
550-
"urlconf": null,
551540
"external_builds_enabled": false,
552541
"external_builds_privacy_level": "public",
553542
"cdn_enabled": false,
@@ -600,7 +589,6 @@
600589
"default_branch": null,
601590
"requirements_file": null,
602591
"documentation_type": "sphinx",
603-
"urlconf": null,
604592
"external_builds_enabled": false,
605593
"external_builds_privacy_level": "public",
606594
"cdn_enabled": false,
@@ -653,7 +641,6 @@
653641
"default_branch": null,
654642
"requirements_file": null,
655643
"documentation_type": "sphinx",
656-
"urlconf": null,
657644
"external_builds_enabled": false,
658645
"external_builds_privacy_level": "public",
659646
"cdn_enabled": false,
@@ -706,7 +693,6 @@
706693
"default_branch": null,
707694
"requirements_file": null,
708695
"documentation_type": "sphinx",
709-
"urlconf": null,
710696
"external_builds_enabled": false,
711697
"external_builds_privacy_level": "public",
712698
"cdn_enabled": false,
@@ -757,7 +743,6 @@
757743
"default_branch": null,
758744
"requirements_file": null,
759745
"documentation_type": "sphinx",
760-
"urlconf": null,
761746
"external_builds_enabled": false,
762747
"external_builds_privacy_level": "public",
763748
"cdn_enabled": false,
@@ -808,7 +793,6 @@
808793
"default_branch": null,
809794
"requirements_file": null,
810795
"documentation_type": "sphinx",
811-
"urlconf": null,
812796
"external_builds_enabled": false,
813797
"external_builds_privacy_level": "public",
814798
"cdn_enabled": false,
@@ -859,7 +843,6 @@
859843
"default_branch": null,
860844
"requirements_file": null,
861845
"documentation_type": "sphinx",
862-
"urlconf": null,
863846
"external_builds_enabled": false,
864847
"external_builds_privacy_level": "public",
865848
"cdn_enabled": false,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Generated by Django 4.2.4 on 2023-08-23 20:35
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("projects", "0104_alter_httpheader_value"),
9+
]
10+
11+
operations = [
12+
migrations.RemoveField(
13+
model_name="historicalproject",
14+
name="urlconf",
15+
),
16+
migrations.RemoveField(
17+
model_name="project",
18+
name="urlconf",
19+
),
20+
]

0 commit comments

Comments
 (0)