Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ninja_extra/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
THROTTLED_OBJECTS = "__throttled_objects__"
ROUTE_FUNCTION = "__route_function__"

CONTROLLER_OPERATION_HANDLER_KEY = "CONTROLLER_OPERATION_HANDLER"
CONTROLLER_WATERMARK = "CONTROLLER_WATERMARK"
ROUTE_OBJECT = "ROUTE_OBJECT"
ROUTE_OBJECT_FUNCTION = "ROUTE_OBJECT_FUNCTION"
OPERATION_ENDPOINT_KEY = "OPERATION_ENDPOINT_KEY"
API_CONTROLLER_INSTANCE = "API_CONTROLLER_INSTANCE"
ORDERATOR_OBJECT = "ORDERATOR_WATERMARK"
SEARCH_OPERATOR_OBJECT = "SEARCH_OPERATOR_OBJECT"
PAGINATOR_OBJECT = "PAGINATOR_WATERMARK"
NINJA_EXTRA_API_CONTROLLER_REGISTERED_KEY = "NINJA_EXTRA_API_CONTROLLER_REGISTERED_KEY"

ROUTE_CONTEXT_VAR: contextvars.ContextVar[t.Optional["RouteContext"]] = (
contextvars.ContextVar("ROUTE_CONTEXT_VAR")
)
Expand Down
5 changes: 5 additions & 0 deletions ninja_extra/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ def __init__(
self._view_signature = view_signature
self._has_computed_route_parameters = False

@property
def api(self) -> "NinjaExtraAPI":
assert self._api, "API instance is not set in RouteContext"
return self._api

@property
def has_computed_route_parameters(self) -> bool:
return self._has_computed_route_parameters
Expand Down
16 changes: 0 additions & 16 deletions ninja_extra/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import typing as t
import warnings

from .base import ControllerBase, ModelControllerBase, api_controller
from .model import (
ModelAsyncEndpointFactory,
Expand Down Expand Up @@ -49,16 +46,3 @@
"ModelEndpointFactory",
"ModelAsyncEndpointFactory",
]


def __getattr__(name: str) -> t.Any:
if name == "RouteContext":
warnings.warn(
"RouteContext is deprecated and will be removed in a future version.",
DeprecationWarning,
stacklevel=2,
)
from ninja_extra.context import RouteContext

return RouteContext
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
Loading