Repository: wagtail/wagtail
File: wagtail/models/__init__.py (Python)

Code before:
    def check_request_method(self, request, *args, **kwargs):
        """
        Checks the ``method`` attribute of the request against those supported
        by the page (as defined by :attr:`allowed_http_methods`) and responds
        accordingly.

        If supported, ``None`` is returned, and the request is processed
        normally. If not, a warning is logged and an ``HttpResponseNotAllowed``
        is returned, and any further request handling is terminated.
        """
        allowed_methods = self.allowed_http_method_names()
        if request.method not in allowed_methods:
            logger.warning(
                "Method Not Allowed (%s): %s",
                request.method,
                request.path,
                extra={"status_code": 405, "request": request},
            )
            return HttpResponseNotAllowed(allowed_methods)

    def handle_options_request(self, request, *args, **kwargs):
        """
        Returns an ``HttpResponse`` with an ``"Allow"`` header containing the list of
        supported HTTP methods for this page. This method is used instead of
        :meth:`serve` to handle requests when the OPTIONS HTTP verb is detected (and
        :attr:`http.HTTPMethod.OPTIONS` is present in :attr:`allowed_http_methods`
        for this type of page).
        """
        return HttpResponse(
            headers={"Allow": ", ".join(self.allowed_http_method_names())}
        )

    def is_navigable(self):
        """
        Return true if it's meaningful to browse subpages of this page -
        i.e. it currently has subpages,
        or it's at the top level (this rule necessary for empty out-of-the-box sites to have working navigation)
        """
        return (not self.is_leaf()) or self.depth == 2

    def _get_site_root_paths(self, request=None):
        """
        Return ``Site.get_site_root_paths()``, using the cached copy on the
        request object if available.
        """
        # if we have a request, use that to cache site_root_paths; otherwise, use self
        cache_object = request if request else self
        try:
            return cache_object._wagtail_cached_site_root_paths
        except AttributeError:
            cache_object._wagtail_cached_site_root_paths = Site.get_site_root_paths()

Review comment (suggestion):
This kept causing issues, spent about 30mins trying to get this resolved.

This did not work (even though we have Intersphinx configured), any tips @laymonage 
```
:attr:`python:http.HTTPMethod.OPTIONS`
``` 

I also tried importing the `http` module `import http # noqa: F401` but this did not work either.

For now I will just remove the attr reference.

> /code/wagtail/wagtail/models/__init__.py:docstring of wagtail.models.Page.handle_options_request:1:py:attr reference target not found: http.HTTPMethod.OPTIONS


Code after:
        return self.get_context(request)

    def get_template(self, request, *args, **kwargs):
        if request.headers.get("x-requested-with") == "XMLHttpRequest":
            return self.ajax_template or self.template
        else:
            return self.template

    def get_preview_template(self, request, mode_name):
        return self.get_template(request)

    def serve(self, request, *args, **kwargs):
        request.is_preview = False

        return TemplateResponse(
            request,
            self.get_template(request, *args, **kwargs),
            self.get_context(request, *args, **kwargs),
        )

    def check_request_method(self, request, *args, **kwargs):
        """
        Checks the ``method`` attribute of the request against those supported
        by the page (as defined by :attr:`allowed_http_methods`) and responds
        accordingly.

        If supported, ``None`` is returned, and the request is processed
        normally. If not, a warning is logged and an ``HttpResponseNotAllowed``
        is returned, and any further request handling is terminated.
        """
        allowed_methods = self.allowed_http_method_names()
        if request.method not in allowed_methods:
            logger.warning(
                "Method Not Allowed (%s): %s",
                request.method,
                request.path,
                extra={"status_code": 405, "request": request},
            )
            return HttpResponseNotAllowed(allowed_methods)

    def handle_options_request(self, request, *args, **kwargs):
        """
        Returns an ``HttpResponse`` with an ``"Allow"`` header containing the list of
        supported HTTP methods for this page. This method is used instead of
        :meth:`serve` to handle requests when the OPTIONS HTTP verb is detected (and
        ``http.HTTPMethod.OPTIONS`` is present in :attr:`allowed_http_methods`
        for this type of page).
        """
        return HttpResponse(
            headers={"Allow": ", ".join(self.allowed_http_method_names())}
        )