Analyzer::Python::Django
Inherits Analyzer::Python::PythonEngine < Analyzer < FileHelper < Reference < Object
Constants
HTTP_METHODS is a fixed table (from PythonEngine), so the
decorator-stack scan and the request.method == "..." scan below
(each an .each loop run per decorator line / per function-body
line) can look up a precompiled regex per method name instead of
interpolating and recompiling one on every iteration. Purely a
lookup-table hoist — the matched text/capture groups are unchanged,
so it doesn't affect the line/offset values computed elsewhere in
this file.
DECORATOR_METHOD_NAME_REGEXES also uses HTTP_METHODS_EXCLUDING_QUERY,
for the OTHER reason that constant documents: it bare-word-matches a
method name anywhere in a decorator's text (this scan is not CBV-
specific — it runs over the decorator stack above a plain function
too), and real decorators (e.g. DRF-spectacular's
OpenApiParameter("query", ...)) commonly carry query as a
parameter name rather than a verb restriction.
REQUEST_METHOD_NAME_REGEXES keeps the full list: it only fires on
an explicit, quoted request.method == "QUERY" comparison, which is
unambiguous developer-written evidence, not a name collision.
def get(...) / async def post(...) method heads in class-based
views. Precompiled — an interpolated literal would be recompiled on
every line of every CBV class body. Uses HTTP_METHODS_EXCLUDING_QUERY
(see PythonEngine): Django's CBV dispatch (View.dispatch) looks up
request.method.lower() against the class's http_method_names
allowlist, which does not include query upstream — unlike Flask's
duck-typed getattr(self, request.method.lower()) dispatch, a
def query(self): method is genuinely inert unless a view manually
widens that allowlist, so matching it here would report a phantom
route.
Regular expressions for extracting Django URL configurations
Map request parameters to their respective fields
Precompiled per-field access patterns so extract_params_from_line
never rebuilds a PCRE2 regex per request field. Compiled once from
REQUEST_PARAM_FIELD_MAP. {field_name, field_methods, param_type,
bracket_re, get_re}
Map request parameter types to HTTP methods
Class methods
Instance methods
Extract endpoints from a Django URL configuration file
Extract endpoints from a given file
Extract parameters from a line of code
Instance-side view of the same declaration. The per-file rescues live on
this base class, which has no way to name the analyzer that is running
inside them, so a skipped file could not be attributed to a tech.
Deriving it from analyzer_for keeps the name written exactly once.