tina4-python 3.13.46__tar.gz → 3.13.48__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tina4_python-3.13.46 → tina4_python-3.13.48}/PKG-INFO +1 -1
- {tina4_python-3.13.46 → tina4_python-3.13.48}/pyproject.toml +1 -1
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/__init__.py +1 -1
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/core/router.py +7 -8
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/core/server.py +37 -6
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/i18n/__init__.py +59 -20
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/migration/runner.py +126 -48
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/__init__.py +24 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/swagger/__init__.py +14 -82
- {tina4_python-3.13.46 → tina4_python-3.13.48}/.gitignore +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/README.md +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/CLAUDE.md +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/HtmlElement.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/Testing.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/ai/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/api/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/auth/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/cache/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/cli/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/container/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/core/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/core/cache.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/core/constants.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/core/events.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/core/middleware.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/core/rate_limiter.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/core/request.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/core/response.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/crud/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/database/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/database/adapter.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/database/connection.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/database/firebird.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/database/mongodb.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/database/mssql.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/database/mysql.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/database/odbc.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/database/postgres.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/database/sqlite.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/debug/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/debug/error_overlay.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/dev_admin/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/dev_admin/metrics.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/dev_admin/plan.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/dev_admin/project_index.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/docs.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/docstore/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/dotenv/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/env.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/frond/FROND.md +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/frond/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/frond/engine.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/auth/meta.json +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/auth/src/routes/api/gallery_auth.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/database/meta.json +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/database/src/routes/api/gallery_db.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/error-overlay/meta.json +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/error-overlay/src/routes/api/gallery_crash.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/orm/meta.json +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/orm/src/orm/Product.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/orm/src/routes/api/gallery_products.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/queue/meta.json +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/queue/src/routes/api/gallery_queue.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/rest-api/meta.json +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/rest-api/src/routes/api/gallery_hello.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/templates/meta.json +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/templates/src/routes/gallery_page.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/gallery/templates/src/templates/gallery_page.twig +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/graphql/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/mcp/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/mcp/protocol.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/mcp/tools.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/messenger/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/migration/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/orm/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/orm/fields.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/orm/model.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/public/__feedback/widget.js +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/public/css/tina4.css +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/public/css/tina4.min.css +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/public/favicon.ico +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/public/images/logo.svg +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/public/images/tina4-logo-icon.webp +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/public/js/frond.js +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/public/js/frond.min.js +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/public/js/tina4-dev-admin.js +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/public/js/tina4-dev-admin.min.js +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/public/js/tina4.min.js +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/public/js/tina4js.min.js +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/public/swagger/index.html +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/public/swagger/oauth2-redirect.html +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/query_builder/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/queue/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/queue/job.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/queue/kafka_backend.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/queue/lite_backend.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/queue/mongo_backend.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/queue/rabbitmq_backend.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/queue_backends/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/queue_backends/kafka_backend.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/queue_backends/mongo_backend.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/queue_backends/rabbitmq_backend.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/_alerts.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/_badges.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/_buttons.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/_cards.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/_forms.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/_grid.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/_modals.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/_nav.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/_reset.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/_tables.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/_typography.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/_utilities.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/_variables.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/base.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/colors.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/scss/tina4css/tina4.scss +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/seeder/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/service/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/session/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/session_handlers/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/session_handlers/mongodb_handler.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/session_handlers/redis_handler.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/session_handlers/valkey_handler.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/components/crud.twig +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/docker/distroless/Dockerfile +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/docker/poetry/Dockerfile +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/docker/python/Dockerfile +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/docker/uv/Dockerfile +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/errors/302.twig +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/errors/401.twig +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/errors/403.twig +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/errors/404.twig +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/errors/500.twig +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/errors/502.twig +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/errors/503.twig +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/errors/base.twig +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/frontend/README.md +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/templates/readme.md +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/test/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/test_client/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/translations/af/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/translations/af/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/translations/en/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/translations/en/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/translations/es/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/translations/es/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/translations/fr/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/translations/fr/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/translations/ja/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/translations/ja/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/translations/zh/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/translations/zh/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/validator/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/websocket/__init__.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/websocket/backplane.py +0 -0
- {tina4_python-3.13.46 → tina4_python-3.13.48}/tina4_python/wsdl/__init__.py +0 -0
|
@@ -219,18 +219,17 @@ class Router:
|
|
|
219
219
|
"""Register a global middleware class applied to every route.
|
|
220
220
|
|
|
221
221
|
Equivalent to decorating every handler with @middleware(middleware_class).
|
|
222
|
+
Delegates to the single ``Middleware`` global registry that the request
|
|
223
|
+
dispatcher actually consults — mirrors PHP ``Router::use`` ->
|
|
224
|
+
``Middleware::use``, Ruby ``Router.use`` -> ``Middleware.use`` and the
|
|
225
|
+
Node equivalent. (Before #55 this wrote to a private ``Router._global_middleware``
|
|
226
|
+
list that nothing read, so globals registered via ``Router.use`` never ran.)
|
|
222
227
|
|
|
223
228
|
Args:
|
|
224
229
|
middleware_class: A class with before_*/after_* static methods.
|
|
225
230
|
"""
|
|
226
|
-
from tina4_python.core import
|
|
227
|
-
|
|
228
|
-
_mw_module.register_global(middleware_class)
|
|
229
|
-
else:
|
|
230
|
-
# Fallback: store in a module-level list the dispatcher can pick up.
|
|
231
|
-
if not hasattr(cls, "_global_middleware"):
|
|
232
|
-
cls._global_middleware = []
|
|
233
|
-
cls._global_middleware.append(middleware_class)
|
|
231
|
+
from tina4_python.core.middleware import Middleware # avoid circular import
|
|
232
|
+
Middleware.use(middleware_class)
|
|
234
233
|
|
|
235
234
|
@classmethod
|
|
236
235
|
def get(cls, path: str, handler, middleware: list = None, swagger_meta: dict = None, template: str = None, **options) -> "RouteRef":
|
|
@@ -127,10 +127,19 @@ def _auto_discover(root_dir: str = "src"):
|
|
|
127
127
|
importlib.import_module(module_name)
|
|
128
128
|
_discovered_mtimes[module_name] = current_mtime
|
|
129
129
|
Log.debug(f"Loaded: {module_name}")
|
|
130
|
-
elif
|
|
131
|
-
#
|
|
132
|
-
#
|
|
133
|
-
#
|
|
130
|
+
elif module_name not in _discovered_mtimes:
|
|
131
|
+
# Already in sys.modules but NEVER recorded by discovery — it was
|
|
132
|
+
# imported TRANSITIVELY (e.g. `from src.x import y` pulled it in
|
|
133
|
+
# before the walk reached its file). Record its current mtime as
|
|
134
|
+
# the baseline WITHOUT re-importing. Re-importing here would
|
|
135
|
+
# del+re-add a fresh module object, while the earlier importer
|
|
136
|
+
# keeps the STALE one — module-level singletons would silently
|
|
137
|
+
# diverge (issue #53). We only ever reload a module WE loaded.
|
|
138
|
+
_discovered_mtimes[module_name] = current_mtime
|
|
139
|
+
elif current_mtime > _discovered_mtimes[module_name]:
|
|
140
|
+
# Changed since WE loaded it — re-execute so edits to an existing
|
|
141
|
+
# route take effect in-process. Scope guard: only ever evict a
|
|
142
|
+
# module that lives under our discovery package. Deleting a
|
|
134
143
|
# tina4_python.* / third-party module would break shared
|
|
135
144
|
# singletons and class identity — never do that here.
|
|
136
145
|
if module_name == root_pkg or module_name.startswith(root_pkg + "."):
|
|
@@ -1322,6 +1331,28 @@ def _middleware_500(response: Response, mw_inst, method_name: str, error: Except
|
|
|
1322
1331
|
})
|
|
1323
1332
|
|
|
1324
1333
|
|
|
1334
|
+
def _effective_middleware(route: dict) -> list:
|
|
1335
|
+
"""Resolve the middleware that actually runs for a route.
|
|
1336
|
+
|
|
1337
|
+
Global middleware (registered via ``Middleware.use`` / ``Router.use``) runs
|
|
1338
|
+
on EVERY route, BEFORE the route's own middleware, in registration order.
|
|
1339
|
+
The list is deduped (by class) so a class that is both global and attached
|
|
1340
|
+
to the route runs once. This is the fix for issue #55 — globals were
|
|
1341
|
+
registered into ``Middleware._global_middleware`` but the dispatcher only
|
|
1342
|
+
ever iterated ``route["middleware"]``, so global middleware never ran.
|
|
1343
|
+
Mirrors the PHP/Ruby/Node dispatchers, which already fold globals in.
|
|
1344
|
+
"""
|
|
1345
|
+
from tina4_python.core.middleware import Middleware
|
|
1346
|
+
resolved = []
|
|
1347
|
+
seen = set()
|
|
1348
|
+
for mw in list(Middleware.get_global()) + list(route.get("middleware", [])):
|
|
1349
|
+
key = mw if isinstance(mw, type) else type(mw)
|
|
1350
|
+
if key not in seen:
|
|
1351
|
+
seen.add(key)
|
|
1352
|
+
resolved.append(mw)
|
|
1353
|
+
return resolved
|
|
1354
|
+
|
|
1355
|
+
|
|
1325
1356
|
def _run_before_middleware(request: Request, response: Response, route: dict) -> tuple[Request, Response, bool]:
|
|
1326
1357
|
"""Run class-based before_* middleware methods. Returns (request, response, skip_handler).
|
|
1327
1358
|
|
|
@@ -1338,7 +1369,7 @@ def _run_before_middleware(request: Request, response: Response, route: dict) ->
|
|
|
1338
1369
|
before_* that sets status >= 400 also short-circuits the handler.
|
|
1339
1370
|
"""
|
|
1340
1371
|
skip = False
|
|
1341
|
-
for _mw_cls in route
|
|
1372
|
+
for _mw_cls in _effective_middleware(route):
|
|
1342
1373
|
if _is_function_middleware(_mw_cls):
|
|
1343
1374
|
continue # Handled by the continuation wrapper instead
|
|
1344
1375
|
_mw_inst = _mw_cls() if isinstance(_mw_cls, type) else _mw_cls
|
|
@@ -1378,7 +1409,7 @@ def _run_after_middleware(request: Request, response: Response, route: dict) ->
|
|
|
1378
1409
|
Resilience (M2): each after_* call is wrapped — a method that THROWS is
|
|
1379
1410
|
logged and converted to a clean 500; remaining after_* still run.
|
|
1380
1411
|
"""
|
|
1381
|
-
for _mw_cls in route
|
|
1412
|
+
for _mw_cls in _effective_middleware(route):
|
|
1382
1413
|
if _is_function_middleware(_mw_cls):
|
|
1383
1414
|
continue
|
|
1384
1415
|
_mw_inst = _mw_cls() if isinstance(_mw_cls, type) else _mw_cls
|
|
@@ -9,10 +9,27 @@ Simple key-based translations loaded from JSON files.
|
|
|
9
9
|
_("greeting") # "Hello" or "Bonjour" depending on locale
|
|
10
10
|
"""
|
|
11
11
|
import os
|
|
12
|
+
import re
|
|
12
13
|
import json
|
|
13
14
|
from pathlib import Path
|
|
14
15
|
|
|
15
16
|
|
|
17
|
+
_PLACEHOLDER = re.compile(r"\{(\w+)\}")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _interpolate(template: str, params: dict) -> str:
|
|
21
|
+
"""Substitute {name} placeholders from params.
|
|
22
|
+
|
|
23
|
+
Partial + literal-leftover: a placeholder present in params is replaced; a
|
|
24
|
+
missing or malformed placeholder ({x.y}, {n:d}, a lone brace) is left
|
|
25
|
+
untouched. Never raises -- a bad template must not crash t().
|
|
26
|
+
"""
|
|
27
|
+
return _PLACEHOLDER.sub(
|
|
28
|
+
lambda m: str(params[m.group(1)]) if m.group(1) in params else m.group(0),
|
|
29
|
+
template,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
16
33
|
class I18n:
|
|
17
34
|
"""Internationalization support with JSON translation files.
|
|
18
35
|
|
|
@@ -61,12 +78,11 @@ class I18n:
|
|
|
61
78
|
if value is None:
|
|
62
79
|
value = key
|
|
63
80
|
|
|
64
|
-
# Interpolate
|
|
81
|
+
# Interpolate {placeholder} tokens. Partial substitution: each token
|
|
82
|
+
# present in kwargs is replaced; a missing or malformed placeholder is
|
|
83
|
+
# left literal. Never raises (a bad template must not crash t()).
|
|
65
84
|
if kwargs:
|
|
66
|
-
|
|
67
|
-
value = value.format(**kwargs)
|
|
68
|
-
except (KeyError, IndexError):
|
|
69
|
-
pass
|
|
85
|
+
value = _interpolate(value, kwargs)
|
|
70
86
|
|
|
71
87
|
return value
|
|
72
88
|
|
|
@@ -86,9 +102,10 @@ class I18n:
|
|
|
86
102
|
if locale:
|
|
87
103
|
old = self._current_locale
|
|
88
104
|
self.locale = locale
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
105
|
+
try:
|
|
106
|
+
return self.t(key, **(params or {}))
|
|
107
|
+
finally:
|
|
108
|
+
self.locale = old
|
|
92
109
|
return self.t(key, **(params or {}))
|
|
93
110
|
|
|
94
111
|
def load_translations(self, locale: str) -> dict:
|
|
@@ -183,28 +200,50 @@ class I18n:
|
|
|
183
200
|
|
|
184
201
|
@staticmethod
|
|
185
202
|
def _flatten(data: dict, prefix: str = "") -> dict:
|
|
186
|
-
"""Flatten nested dict
|
|
203
|
+
"""Flatten a nested dict to dot-paths, then add leaf-key aliases.
|
|
187
204
|
|
|
188
|
-
{"nav": {"home": "Home"}}
|
|
205
|
+
{"nav": {"home": "Home"}} -> {"nav.home": "Home", "home": "Home"}
|
|
189
206
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
207
|
+
Two passes so the alias rule is correct:
|
|
208
|
+
1. Flatten to full dot-path keys only.
|
|
209
|
+
2. Add each leaf key as a shortcut ONLY if it is not already present.
|
|
210
|
+
|
|
211
|
+
So the FIRST dot-path wins on a leaf-key collision, and an explicit
|
|
212
|
+
top-level flat key is never overwritten by a derived alias. (The old
|
|
213
|
+
single-pass recursive merge was last-wins and could clobber an
|
|
214
|
+
explicit flat key -- silent data loss.)
|
|
194
215
|
"""
|
|
216
|
+
flat = I18n._flatten_paths(data, prefix)
|
|
217
|
+
result = dict(flat)
|
|
218
|
+
for full_key, value in flat.items():
|
|
219
|
+
leaf = full_key.rsplit(".", 1)[-1]
|
|
220
|
+
if leaf not in result:
|
|
221
|
+
result[leaf] = value
|
|
222
|
+
return result
|
|
223
|
+
|
|
224
|
+
@staticmethod
|
|
225
|
+
def _flatten_paths(data: dict, prefix: str = "") -> dict:
|
|
226
|
+
"""Flatten a nested dict to dot-path keys only (no leaf aliasing)."""
|
|
195
227
|
result = {}
|
|
196
228
|
for key, value in data.items():
|
|
197
229
|
full_key = f"{prefix}.{key}" if prefix else key
|
|
198
230
|
if isinstance(value, dict):
|
|
199
|
-
result.update(I18n.
|
|
231
|
+
result.update(I18n._flatten_paths(value, full_key))
|
|
200
232
|
else:
|
|
201
|
-
|
|
202
|
-
result[full_key] = str_value
|
|
203
|
-
# Also store the leaf key as a shortcut (first-wins on conflict)
|
|
204
|
-
if key not in result:
|
|
205
|
-
result[key] = str_value
|
|
233
|
+
result[full_key] = I18n._coerce_scalar(value)
|
|
206
234
|
return result
|
|
207
235
|
|
|
236
|
+
@staticmethod
|
|
237
|
+
def _coerce_scalar(value) -> str:
|
|
238
|
+
"""Render a non-string locale scalar JSON-natively (true/false/null)."""
|
|
239
|
+
if value is True:
|
|
240
|
+
return "true"
|
|
241
|
+
if value is False:
|
|
242
|
+
return "false"
|
|
243
|
+
if value is None:
|
|
244
|
+
return "null"
|
|
245
|
+
return str(value)
|
|
246
|
+
|
|
208
247
|
@staticmethod
|
|
209
248
|
def _resolve(key: str, translations: dict) -> str | None:
|
|
210
249
|
return translations.get(key)
|
|
@@ -332,59 +332,137 @@ def _normalize_quotes(sql: str) -> str:
|
|
|
332
332
|
|
|
333
333
|
|
|
334
334
|
def _split_statements(sql: str, delimiter: str = ";") -> list[str]:
|
|
335
|
-
"""Split SQL into individual statements
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
335
|
+
"""Split SQL into individual statements with a single-pass, quote- and
|
|
336
|
+
comment-aware scanner.
|
|
337
|
+
|
|
338
|
+
The split decision is made character by character so the delimiter only ever
|
|
339
|
+
fires in real statement position. This is the fix for issue #54: the old
|
|
340
|
+
implementation split on ``delimiter`` BEFORE stripping ``-- …`` line comments,
|
|
341
|
+
so a ``;`` *inside* a line comment fragmented one statement into several
|
|
342
|
+
broken pieces. A scanner that knows where it is — code, comment, or string —
|
|
343
|
+
cannot make that mistake.
|
|
344
|
+
|
|
345
|
+
Handled, in priority order, only when NOT already inside a stored-proc block:
|
|
346
|
+
|
|
347
|
+
- **Stored-procedure blocks** delimited by ``$$`` or ``//`` are kept intact
|
|
348
|
+
(their inner ``;`` never splits). A ``//`` preceded by ``:`` is a URL
|
|
349
|
+
scheme (``https://…``), not a block delimiter, so it is left alone.
|
|
350
|
+
- **Block comments** ``/* … */`` are stripped.
|
|
351
|
+
- **Line comments** ``-- …`` are stripped to end of line (the newline is
|
|
352
|
+
kept, so line structure survives). A ``;`` here never splits.
|
|
353
|
+
- **String literals** — single-quoted ``'…'`` and double-quoted identifiers
|
|
354
|
+
``"…"`` — are copied verbatim, honouring the SQL doubled-quote escape
|
|
355
|
+
(``''`` / ``""``). A ``;``, ``--`` or ``/*`` inside a literal is data, not
|
|
356
|
+
a delimiter or comment, so it is preserved untouched.
|
|
357
|
+
- The **delimiter** ends a statement only when reached outside all of the
|
|
358
|
+
above. Empty statements are dropped; each kept statement is trimmed.
|
|
359
|
+
|
|
360
|
+
Smart/curly quotes are normalized to straight ASCII first. Mirrors the
|
|
361
|
+
tina4-php ``Migration::splitStatements`` scanner for cross-framework parity.
|
|
345
362
|
"""
|
|
346
363
|
# Normalize smart/curly quotes to straight ASCII first, so SQL pasted from
|
|
347
364
|
# an editor/doc (which converts " → “ ” and ' → ‘ ’) actually runs.
|
|
348
365
|
sql = _normalize_quotes(sql)
|
|
349
366
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
#
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
if
|
|
387
|
-
|
|
367
|
+
statements: list[str] = []
|
|
368
|
+
current: list[str] = []
|
|
369
|
+
n = len(sql)
|
|
370
|
+
dlen = len(delimiter)
|
|
371
|
+
i = 0
|
|
372
|
+
in_dollar_block = False
|
|
373
|
+
in_slash_block = False
|
|
374
|
+
|
|
375
|
+
while i < n:
|
|
376
|
+
ch = sql[i]
|
|
377
|
+
|
|
378
|
+
# $$ … $$ stored-proc block (toggle in/out).
|
|
379
|
+
if not in_slash_block and ch == "$" and i + 1 < n and sql[i + 1] == "$":
|
|
380
|
+
current.append("$$")
|
|
381
|
+
i += 2
|
|
382
|
+
in_dollar_block = not in_dollar_block
|
|
383
|
+
continue
|
|
384
|
+
|
|
385
|
+
# // … // stored-proc block (toggle). The `//` must NOT be preceded by a
|
|
386
|
+
# colon, so a URL scheme (`https://…`) or any `://` literal is never
|
|
387
|
+
# treated as a block delimiter (it would otherwise swallow everything
|
|
388
|
+
# between two `//` occurrences and skip statement splitting).
|
|
389
|
+
if (not in_dollar_block and ch == "/" and i + 1 < n and sql[i + 1] == "/"
|
|
390
|
+
and not (i > 0 and sql[i - 1] == ":")):
|
|
391
|
+
current.append("//")
|
|
392
|
+
i += 2
|
|
393
|
+
in_slash_block = not in_slash_block
|
|
394
|
+
continue
|
|
395
|
+
|
|
396
|
+
# Inside a stored-proc block: consume verbatim (inner ; never splits).
|
|
397
|
+
if in_dollar_block or in_slash_block:
|
|
398
|
+
current.append(ch)
|
|
399
|
+
i += 1
|
|
400
|
+
continue
|
|
401
|
+
|
|
402
|
+
# Block comment /* … */ — stripped.
|
|
403
|
+
if ch == "/" and i + 1 < n and sql[i + 1] == "*":
|
|
404
|
+
end = sql.find("*/", i + 2)
|
|
405
|
+
i = (end + 2) if end != -1 else n
|
|
406
|
+
continue
|
|
407
|
+
|
|
408
|
+
# Line comment -- … — stripped to end of line; the newline is left for
|
|
409
|
+
# the next iteration so line structure (and statement boundaries on the
|
|
410
|
+
# NEXT line) survive. A ';' inside the comment is NOT a delimiter.
|
|
411
|
+
if ch == "-" and i + 1 < n and sql[i + 1] == "-":
|
|
412
|
+
end = sql.find("\n", i + 2)
|
|
413
|
+
i = end if end != -1 else n
|
|
414
|
+
continue
|
|
415
|
+
|
|
416
|
+
# Single-quoted string literal — '' escapes a quote. Copied verbatim so a
|
|
417
|
+
# ';' / '--' / '/*' inside the value is data, not a delimiter/comment.
|
|
418
|
+
if ch == "'":
|
|
419
|
+
current.append("'")
|
|
420
|
+
i += 1
|
|
421
|
+
while i < n:
|
|
422
|
+
if sql[i] == "'" and i + 1 < n and sql[i + 1] == "'":
|
|
423
|
+
current.append("''")
|
|
424
|
+
i += 2
|
|
425
|
+
elif sql[i] == "'":
|
|
426
|
+
current.append("'")
|
|
427
|
+
i += 1
|
|
428
|
+
break
|
|
429
|
+
else:
|
|
430
|
+
current.append(sql[i])
|
|
431
|
+
i += 1
|
|
432
|
+
continue
|
|
433
|
+
|
|
434
|
+
# Double-quoted identifier — "" escapes a quote. Same verbatim handling.
|
|
435
|
+
if ch == '"':
|
|
436
|
+
current.append('"')
|
|
437
|
+
i += 1
|
|
438
|
+
while i < n:
|
|
439
|
+
if sql[i] == '"' and i + 1 < n and sql[i + 1] == '"':
|
|
440
|
+
current.append('""')
|
|
441
|
+
i += 2
|
|
442
|
+
elif sql[i] == '"':
|
|
443
|
+
current.append('"')
|
|
444
|
+
i += 1
|
|
445
|
+
break
|
|
446
|
+
else:
|
|
447
|
+
current.append(sql[i])
|
|
448
|
+
i += 1
|
|
449
|
+
continue
|
|
450
|
+
|
|
451
|
+
# Statement delimiter — only reached outside blocks/comments/strings.
|
|
452
|
+
if delimiter and sql.startswith(delimiter, i):
|
|
453
|
+
stmt = "".join(current).strip()
|
|
454
|
+
if stmt:
|
|
455
|
+
statements.append(stmt)
|
|
456
|
+
current = []
|
|
457
|
+
i += dlen
|
|
458
|
+
continue
|
|
459
|
+
|
|
460
|
+
current.append(ch)
|
|
461
|
+
i += 1
|
|
462
|
+
|
|
463
|
+
stmt = "".join(current).strip()
|
|
464
|
+
if stmt:
|
|
465
|
+
statements.append(stmt)
|
|
388
466
|
return statements
|
|
389
467
|
|
|
390
468
|
|
|
@@ -131,6 +131,9 @@ def _compile(scss: str) -> str:
|
|
|
131
131
|
# 6. Resolve @extend
|
|
132
132
|
scss = _resolve_extends(scss, placeholders)
|
|
133
133
|
|
|
134
|
+
# 6.5. Resolve #{ ... } interpolation (before $var substitution + nesting).
|
|
135
|
+
scss = _resolve_interpolation(scss, variables)
|
|
136
|
+
|
|
134
137
|
# 7. Substitute variables
|
|
135
138
|
scss = _substitute_variables(scss, variables)
|
|
136
139
|
|
|
@@ -171,6 +174,27 @@ def _substitute_variables(scss: str, variables: dict) -> str:
|
|
|
171
174
|
return scss
|
|
172
175
|
|
|
173
176
|
|
|
177
|
+
def _resolve_interpolation(scss: str, variables: dict) -> str:
|
|
178
|
+
"""Resolve SCSS ``#{ ... }`` interpolation.
|
|
179
|
+
|
|
180
|
+
Each ``#{ expr }`` is replaced by its resolved inner text: a ``$variable``
|
|
181
|
+
inside the braces resolves to its value, anything else is inlined verbatim
|
|
182
|
+
(trimmed). This lets a value carry a variable inside a string context the
|
|
183
|
+
plain ``$var`` substitution can't reach — e.g. ``calc(100% - #{$gap})`` ->
|
|
184
|
+
``calc(100% - 20px)`` — and lets a variable appear in a selector
|
|
185
|
+
(``.icon-#{$name}`` -> ``.icon-home``). Run BEFORE nested-rule flattening so
|
|
186
|
+
the literal ``{``/``}`` never confuse the block matcher. The inner cannot
|
|
187
|
+
contain braces (interpolation is a leaf expression), so ``[^{}]*`` is safe.
|
|
188
|
+
"""
|
|
189
|
+
def _resolve(m):
|
|
190
|
+
inner = m.group(1).strip()
|
|
191
|
+
for name in sorted(variables.keys(), key=len, reverse=True):
|
|
192
|
+
inner = inner.replace(f"${name}", variables[name])
|
|
193
|
+
return inner
|
|
194
|
+
|
|
195
|
+
return re.sub(r'#\{([^{}]*)\}', _resolve, scss)
|
|
196
|
+
|
|
197
|
+
|
|
174
198
|
def _extract_mixins(scss: str, mixins: dict) -> str:
|
|
175
199
|
"""Extract @mixin definitions."""
|
|
176
200
|
pattern = re.compile(
|
|
@@ -39,23 +39,11 @@ v3.13.42 — configurability for external/public APIs:
|
|
|
39
39
|
import json
|
|
40
40
|
import os
|
|
41
41
|
import re
|
|
42
|
-
import functools
|
|
43
42
|
|
|
44
43
|
|
|
45
44
|
# ── Decorators ─────────────────────────────────────────────────
|
|
46
45
|
# These attach metadata to route handlers for Swagger generation.
|
|
47
46
|
|
|
48
|
-
# Every swagger attr a decorator may need to carry forward when it wraps a
|
|
49
|
-
# handler that another decorator already annotated.
|
|
50
|
-
_SWAGGER_ATTRS = (
|
|
51
|
-
"_swagger_description", "_swagger_detail", "_swagger_params", "_swagger_query",
|
|
52
|
-
"_swagger_summary", "_swagger_tags", "_swagger_example", "_swagger_example_content_type",
|
|
53
|
-
"_swagger_example_response", "_swagger_example_responses", "_swagger_deprecated",
|
|
54
|
-
"_swagger_model", "_swagger_model_list",
|
|
55
|
-
"_swagger_security", "_swagger_request_schema", "_swagger_response_schemas",
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
59
47
|
# ── Configuration registry ─────────────────────────────────────
|
|
60
48
|
# Process-wide registries for security schemes and reusable component schemas
|
|
61
49
|
# declared programmatically (Swagger.add_security_scheme / Swagger.add_schema).
|
|
@@ -65,13 +53,6 @@ _REGISTERED_SCHEMES: dict[str, dict] = {}
|
|
|
65
53
|
_REGISTERED_SCHEMAS: dict[str, dict] = {}
|
|
66
54
|
|
|
67
55
|
|
|
68
|
-
def _carry(fn, wrapper):
|
|
69
|
-
"""Copy any already-set swagger attrs from fn onto wrapper (idempotent)."""
|
|
70
|
-
for attr in _SWAGGER_ATTRS:
|
|
71
|
-
if hasattr(fn, attr) and not hasattr(wrapper, attr):
|
|
72
|
-
setattr(wrapper, attr, getattr(fn, attr))
|
|
73
|
-
|
|
74
|
-
|
|
75
56
|
def description(text: str = "", detail: str = "", params: dict | None = None,
|
|
76
57
|
query: dict | None = None):
|
|
77
58
|
"""Add a description, optional detail body, and parameter docs to a route.
|
|
@@ -99,19 +80,12 @@ def description(text: str = "", detail: str = "", params: dict | None = None,
|
|
|
99
80
|
fn._swagger_params = params
|
|
100
81
|
if query:
|
|
101
82
|
fn._swagger_query = query
|
|
102
|
-
|
|
103
|
-
@
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
wrapper._swagger_detail = detail
|
|
109
|
-
if params:
|
|
110
|
-
wrapper._swagger_params = params
|
|
111
|
-
if query:
|
|
112
|
-
wrapper._swagger_query = query
|
|
113
|
-
_carry(fn, wrapper)
|
|
114
|
-
return wrapper
|
|
83
|
+
# No wrapper: annotate the handler in place and return the SAME object.
|
|
84
|
+
# @get is innermost and registers this exact object, so every stacked
|
|
85
|
+
# decorator must land its metadata here. A wrapper would be registered
|
|
86
|
+
# by nothing (the outer decorators never reach the router) and silently
|
|
87
|
+
# drop all metadata except the decorator adjacent to @get.
|
|
88
|
+
return fn
|
|
115
89
|
return decorator
|
|
116
90
|
|
|
117
91
|
|
|
@@ -119,12 +93,7 @@ def summary(text: str):
|
|
|
119
93
|
"""Add a short summary to a route handler."""
|
|
120
94
|
def decorator(fn):
|
|
121
95
|
fn._swagger_summary = text
|
|
122
|
-
|
|
123
|
-
def wrapper(*args, **kwargs):
|
|
124
|
-
return fn(*args, **kwargs)
|
|
125
|
-
wrapper._swagger_summary = text
|
|
126
|
-
_carry(fn, wrapper)
|
|
127
|
-
return wrapper
|
|
96
|
+
return fn
|
|
128
97
|
return decorator
|
|
129
98
|
|
|
130
99
|
|
|
@@ -140,12 +109,7 @@ def tags(tag_list):
|
|
|
140
109
|
|
|
141
110
|
def decorator(fn):
|
|
142
111
|
fn._swagger_tags = tag_list
|
|
143
|
-
|
|
144
|
-
def wrapper(*args, **kwargs):
|
|
145
|
-
return fn(*args, **kwargs)
|
|
146
|
-
wrapper._swagger_tags = tag_list
|
|
147
|
-
_carry(fn, wrapper)
|
|
148
|
-
return wrapper
|
|
112
|
+
return fn
|
|
149
113
|
return decorator
|
|
150
114
|
|
|
151
115
|
|
|
@@ -160,13 +124,7 @@ def example(data: dict | list, content_type: str = "application/json"):
|
|
|
160
124
|
def decorator(fn):
|
|
161
125
|
fn._swagger_example = data
|
|
162
126
|
fn._swagger_example_content_type = content_type
|
|
163
|
-
|
|
164
|
-
def wrapper(*args, **kwargs):
|
|
165
|
-
return fn(*args, **kwargs)
|
|
166
|
-
wrapper._swagger_example = data
|
|
167
|
-
wrapper._swagger_example_content_type = content_type
|
|
168
|
-
_carry(fn, wrapper)
|
|
169
|
-
return wrapper
|
|
127
|
+
return fn
|
|
170
128
|
return decorator
|
|
171
129
|
|
|
172
130
|
|
|
@@ -198,13 +156,7 @@ def example_response(status_or_data, data=None):
|
|
|
198
156
|
responses[status_code] = body
|
|
199
157
|
fn._swagger_example_responses = responses
|
|
200
158
|
fn._swagger_example_response = body
|
|
201
|
-
|
|
202
|
-
def wrapper(*args, **kwargs):
|
|
203
|
-
return fn(*args, **kwargs)
|
|
204
|
-
wrapper._swagger_example_responses = responses
|
|
205
|
-
wrapper._swagger_example_response = body
|
|
206
|
-
_carry(fn, wrapper)
|
|
207
|
-
return wrapper
|
|
159
|
+
return fn
|
|
208
160
|
return decorator
|
|
209
161
|
|
|
210
162
|
|
|
@@ -212,12 +164,7 @@ def deprecated():
|
|
|
212
164
|
"""Mark a route as deprecated."""
|
|
213
165
|
def decorator(fn):
|
|
214
166
|
fn._swagger_deprecated = True
|
|
215
|
-
|
|
216
|
-
def wrapper(*args, **kwargs):
|
|
217
|
-
return fn(*args, **kwargs)
|
|
218
|
-
wrapper._swagger_deprecated = True
|
|
219
|
-
_carry(fn, wrapper)
|
|
220
|
-
return wrapper
|
|
167
|
+
return fn
|
|
221
168
|
return decorator
|
|
222
169
|
|
|
223
170
|
|
|
@@ -257,12 +204,7 @@ def security(scheme_or_reqs="bearerAuth", scopes=None):
|
|
|
257
204
|
reqs = _normalize_security(scheme_or_reqs, scopes)
|
|
258
205
|
def decorator(fn):
|
|
259
206
|
fn._swagger_security = reqs
|
|
260
|
-
|
|
261
|
-
def wrapper(*args, **kwargs):
|
|
262
|
-
return fn(*args, **kwargs)
|
|
263
|
-
wrapper._swagger_security = reqs
|
|
264
|
-
_carry(fn, wrapper)
|
|
265
|
-
return wrapper
|
|
207
|
+
return fn
|
|
266
208
|
return decorator
|
|
267
209
|
|
|
268
210
|
|
|
@@ -274,12 +216,7 @@ def request_schema(name: str, content_type: str = "application/json"):
|
|
|
274
216
|
"""
|
|
275
217
|
def decorator(fn):
|
|
276
218
|
fn._swagger_request_schema = (name, content_type)
|
|
277
|
-
|
|
278
|
-
def wrapper(*args, **kwargs):
|
|
279
|
-
return fn(*args, **kwargs)
|
|
280
|
-
wrapper._swagger_request_schema = (name, content_type)
|
|
281
|
-
_carry(fn, wrapper)
|
|
282
|
-
return wrapper
|
|
219
|
+
return fn
|
|
283
220
|
return decorator
|
|
284
221
|
|
|
285
222
|
|
|
@@ -294,12 +231,7 @@ def response_schema(name: str, status: int = 200, is_list: bool = False):
|
|
|
294
231
|
existing = dict(getattr(fn, "_swagger_response_schemas", {}) or {})
|
|
295
232
|
existing[int(status)] = (name, bool(is_list))
|
|
296
233
|
fn._swagger_response_schemas = existing
|
|
297
|
-
|
|
298
|
-
def wrapper(*args, **kwargs):
|
|
299
|
-
return fn(*args, **kwargs)
|
|
300
|
-
wrapper._swagger_response_schemas = existing
|
|
301
|
-
_carry(fn, wrapper)
|
|
302
|
-
return wrapper
|
|
234
|
+
return fn
|
|
303
235
|
return decorator
|
|
304
236
|
|
|
305
237
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|