|
56 | 56 | STATIC_URL = "/assets/"
|
57 | 57 | STATIC_ROOT = DEPLOY_ROOT / STATIC_URL.strip("/")
|
58 | 58 |
|
59 |
| -STORAGES = { |
60 |
| - "default": {"BACKEND": "pulpcore.app.models.storage.FileSystem"}, |
61 |
| - "staticfiles": { |
62 |
| - # This is django's default, but when customizing STORAGES we need to add explicitly |
63 |
| - # https://docs.djangoproject.com/en/4.2/ref/settings/#storages |
64 |
| - "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", |
65 |
| - }, |
66 |
| -} |
67 | 59 |
|
68 | 60 | REDIRECT_TO_OBJECT_STORAGE = True
|
69 | 61 |
|
|
371 | 363 |
|
372 | 364 | # HERE STARTS DYNACONF EXTENSION LOAD (Keep at the very bottom of settings.py)
|
373 | 365 | # Read more at https://www.dynaconf.com/django/
|
374 |
| -from dynaconf import DjangoDynaconf, Validator # noqa |
| 366 | +from dynaconf import DjangoDynaconf, Validator, get_history # noqa |
375 | 367 |
|
376 | 368 | # Validators
|
377 | 369 | storage_validator = (
|
@@ -481,13 +473,35 @@ def otel_middleware_hook(settings):
|
481 | 473 | api_root_validator,
|
482 | 474 | cache_validator,
|
483 | 475 | sha256_validator,
|
484 |
| - storage_validator, |
485 | 476 | unknown_algs_validator,
|
486 | 477 | json_header_auth_validator,
|
487 | 478 | authentication_json_header_openapi_security_scheme_validator,
|
488 | 479 | ],
|
489 | 480 | post_hooks=otel_middleware_hook,
|
490 | 481 | )
|
| 482 | + |
| 483 | +# begin Compatiblity Layer for DEFAULT_FILE_STORAGE deprecation (remove in 3.85): |
| 484 | +# |
| 485 | +# 1. Removed DEFAULT_FILE_STORAGE from toplevel setting, because STORAGES and DEFAULT_FILE_STORAGE |
| 486 | +# are mutually exclusive. This enables users to migrate to STORAGES before true removal of the |
| 487 | +# legacy setting. |
| 488 | +# 2. After dropping this compat-layer, put the default STORAGES in the toplevel module, as usual. |
| 489 | +# Then, DEFAULT_FILE_STORAGE would not be allowed anymore. |
| 490 | + |
| 491 | +# Dynamically update default storages backend to use Pulp's special class, |
| 492 | +# but only in the case the user has not provided an explicit setting for it. |
| 493 | +dfstorage_history = get_history(settings, key="DEFAULT_FILE_STORAGE") |
| 494 | +django_default_used = ( |
| 495 | + len(dfstorage_history) == 1 and dfstorage_history[0]["identifier"] == "undefined" |
| 496 | +) |
| 497 | +if django_default_used: |
| 498 | + settings.set("STORAGES.default.BACKEND", "pulpcore.app.models.storage.FileSystem") |
| 499 | + |
| 500 | +settings.validators.register(storage_validator) |
| 501 | +settings.validators.validate(only=["STORAGES.default.BACKEND", "REDIRECT_TO_OBJECT_STORAGE"]) |
| 502 | + |
| 503 | +# end Compatibility Layer |
| 504 | + |
491 | 505 | # HERE ENDS DYNACONF EXTENSION LOAD (No more code below this line)
|
492 | 506 |
|
493 | 507 | _logger = getLogger(__name__)
|
|
0 commit comments