Constructs a versioned url for the given path. This method may be overridden in subclasses (but note that it is a class method rather than an instance method). Subclasses are only required to implement the signature ``make_static_url(cls, settings, path)``; other ke
(
cls, settings: Dict[str, Any], path: str, include_version: bool = True
)
| 2954 | |
| 2955 | @classmethod |
| 2956 | def make_static_url( |
| 2957 | cls, settings: Dict[str, Any], path: str, include_version: bool = True |
| 2958 | ) -> str: |
| 2959 | """Constructs a versioned url for the given path. |
| 2960 | |
| 2961 | This method may be overridden in subclasses (but note that it |
| 2962 | is a class method rather than an instance method). Subclasses |
| 2963 | are only required to implement the signature |
| 2964 | ``make_static_url(cls, settings, path)``; other keyword |
| 2965 | arguments may be passed through `~RequestHandler.static_url` |
| 2966 | but are not standard. |
| 2967 | |
| 2968 | ``settings`` is the `Application.settings` dictionary. ``path`` |
| 2969 | is the static path being requested. The url returned should be |
| 2970 | relative to the current host. |
| 2971 | |
| 2972 | ``include_version`` determines whether the generated URL should |
| 2973 | include the query string containing the version hash of the |
| 2974 | file corresponding to the given ``path``. |
| 2975 | |
| 2976 | """ |
| 2977 | url = settings.get("static_url_prefix", "/static/") + path |
| 2978 | if not include_version: |
| 2979 | return url |
| 2980 | |
| 2981 | version_hash = cls.get_version(settings, path) |
| 2982 | if not version_hash: |
| 2983 | return url |
| 2984 | |
| 2985 | return "%s?v=%s" % (url, version_hash) |
| 2986 | |
| 2987 | def parse_url_path(self, url_path: str) -> str: |
| 2988 | """Converts a static URL path into a filesystem path. |
nothing calls this directly
no test coverage detected