From 8ad0a153c5efb36a36fb55e5ae965ab044ce9979 Mon Sep 17 00:00:00 2001 From: Adam Hopkins Date: Mon, 18 Sep 2023 10:39:45 +0300 Subject: [PATCH] Add vary header --- guide/webapp/display/page/docobject.py | 1 - guide/webapp/display/plugins/inline_directive.py | 2 -- guide/webapp/worker/factory.py | 5 ++++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/guide/webapp/display/page/docobject.py b/guide/webapp/display/page/docobject.py index c84b2179..a543ac72 100644 --- a/guide/webapp/display/page/docobject.py +++ b/guide/webapp/display/page/docobject.py @@ -110,7 +110,6 @@ def organize_docobjects(package_name: str) -> dict[str, str]: docobjects = _extract_docobjects(package_name) page_registry: defaultdict[str, list[str]] = defaultdict(list) for module, docobject in docobjects.items(): - print(f"{module=}") builder = Builder(name="Partial") _docobject_to_html(docobject, builder) ref = module.rsplit(".", module.count(".") - 1)[0] diff --git a/guide/webapp/display/plugins/inline_directive.py b/guide/webapp/display/plugins/inline_directive.py index a3a1a6a4..eb7e21f6 100644 --- a/guide/webapp/display/plugins/inline_directive.py +++ b/guide/webapp/display/plugins/inline_directive.py @@ -5,7 +5,6 @@ from mistune.markdown import Markdown DIRECTIVE_PATTERN = r":(?:class|func|meth|attr|exc|mod|data|const|obj|keyword|option|cmdoption|envvar):`(?Psanic\.[^`]+)`" # noqa: E501 def _parse_inline_directive(inline, m: re.Match, state): - print("inline_directive.py: _parse_inline_directive", m.group("ref")) state.append_token( { "type": "inline_directive", @@ -16,5 +15,4 @@ def _parse_inline_directive(inline, m: re.Match, state): return m.end() def inline_directive(md: Markdown): - print("Registering inline_directive") md.inline.register("inline_directive", DIRECTIVE_PATTERN, _parse_inline_directive, before="escape",) diff --git a/guide/webapp/worker/factory.py b/guide/webapp/worker/factory.py index dc983f09..7ce3b164 100644 --- a/guide/webapp/worker/factory.py +++ b/guide/webapp/worker/factory.py @@ -62,7 +62,10 @@ def create_app(root: Path) -> Sanic: language: str, path: str = "", ): - return html(page_renderer.render(request, language, path)) + return html( + page_renderer.render(request, language, path), + headers={"vary": "hx-request"}, + ) @app.on_request async def set_language(request: Request):