diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-11-11 06:41:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-11-11 06:41:50 +0000 |
commit | e55022477a9408c5f815d81064649c95662df6ac (patch) | |
tree | b935665a6c113e39097f068b8d3a34d6aca8ee8f /src | |
parent | Releasing debian version 0.47+dfsg-2. (diff) | |
download | jinjax-e55022477a9408c5f815d81064649c95662df6ac.tar.xz jinjax-e55022477a9408c5f815d81064649c95662df6ac.zip |
Merging upstream version 0.48+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/jinjax/catalog.py | 1 | ||||
-rw-r--r-- | src/jinjax/middleware.py | 15 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/jinjax/catalog.py b/src/jinjax/catalog.py index 7728ed4..6cb2b70 100644 --- a/src/jinjax/catalog.py +++ b/src/jinjax/catalog.py @@ -12,7 +12,6 @@ from .component import Component from .exceptions import ComponentNotFound, InvalidArgument from .html_attrs import HTMLAttrs from .jinjax import JinjaX -from .middleware import ComponentsMiddleware from .utils import DELIMITER, SLASH, get_url_prefix, logger diff --git a/src/jinjax/middleware.py b/src/jinjax/middleware.py index af430b1..4e8c52e 100644 --- a/src/jinjax/middleware.py +++ b/src/jinjax/middleware.py @@ -6,22 +6,23 @@ from pathlib import Path try: from whitenoise import WhiteNoise from whitenoise.responders import Redirect, StaticFile -except ImportError as err : - raise ImportError( - "This feature requires the package `whitenoise` to be installed. \n" - + "Run `pip install jinjax[whitenoise]` to do it." - ) from err - +except ImportError: + WhiteNoise = object RX_FINGERPRINT = re.compile("(.*)-([abcdef0-9]{64})") -class ComponentsMiddleware(WhiteNoise): +class ComponentsMiddleware(WhiteNoise): # type: ignore """WSGI middleware for serving components assets""" allowed_ext: tuple[str, ...] def __init__(self, **kwargs) -> None: + if WhiteNoise is object: + raise ImportError( + "The ComponentsMiddleware requires the package `whitenoise`" + + " to be installed. \nRun `pip install jinjax[whitenoise]` to do it." + ) self.allowed_ext = kwargs.pop("allowed_ext", ()) super().__init__(**kwargs) |