keepup-admin 0.7.0__tar.gz → 0.7.1__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.
- {keepup_admin-0.7.0/keepup_admin.egg-info → keepup_admin-0.7.1}/PKG-INFO +1 -1
- {keepup_admin-0.7.0 → keepup_admin-0.7.1/keepup_admin.egg-info}/PKG-INFO +1 -1
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/kernel/observability.py +24 -1
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/pyproject.toml +1 -1
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/LICENSE +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/NOTICE +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/README.md +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/THIRD-PARTY.md +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/__init__.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/api_versions.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/builtin/audit.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/builtin/auth.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/builtin/db.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/builtin/postgres.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/builtin/sqlite.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/builtin/ui.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/builtin/users.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/cache.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/clock.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/instance.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/keepup_admin.egg-info/SOURCES.txt +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/keepup_admin.egg-info/dependency_links.txt +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/keepup_admin.egg-info/requires.txt +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/keepup_admin.egg-info/top_level.txt +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/kernel/__init__.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/kernel/call.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/kernel/catalogue.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/kernel/contributions.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/kernel/datasource.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/kernel/descriptor.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/kernel/lifecycle.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/kernel/loader.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/kernel/security.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/kernel/services.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/kernel/transports.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/locks.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/logging_setup.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/notification_bus.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/plugins/__init__.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/plugins/base.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/plugins/builtin.json +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/plugins/enablement.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/plugins/registry.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/plugins/route_mask.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/roles.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/sections.json +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/security.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/settings.py +0 -0
- {keepup_admin-0.7.0 → keepup_admin-0.7.1}/setup.cfg +0 -0
|
@@ -14,6 +14,8 @@ is set at start-up, and a deployment that sets nothing records nothing --
|
|
|
14
14
|
which is a deployment, not a failure.
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
|
+
import asyncio
|
|
18
|
+
import inspect
|
|
17
19
|
from contextlib import asynccontextmanager
|
|
18
20
|
from dataclasses import dataclass, field
|
|
19
21
|
from functools import wraps
|
|
@@ -133,6 +135,27 @@ async def emit(event_type: str, payload: Mapping[str, Any] = None) -> int:
|
|
|
133
135
|
return written
|
|
134
136
|
|
|
135
137
|
|
|
138
|
+
async def _run_route(handler, *args, **kwargs):
|
|
139
|
+
"""Run a route the way the transport would, and hand back its answer.
|
|
140
|
+
|
|
141
|
+
A route is declared either with `async def` or with `def`, and the second is
|
|
142
|
+
a decision rather than an oversight: FastAPI runs a `def` route in a worker
|
|
143
|
+
thread, which is where a database call or a `bcrypt` hash belongs. The audit
|
|
144
|
+
wrapper around it is a coroutine either way, so awaiting a plain function was
|
|
145
|
+
a `TypeError` -- `object dict can't be used in 'await' expression` -- thrown
|
|
146
|
+
*after* the handler had already done its work: (0.7.0) the administrator's
|
|
147
|
+
password change and the profile update applied their change and answered 500
|
|
148
|
+
(keepup-182).
|
|
149
|
+
|
|
150
|
+
A synchronous handler therefore goes to a thread of its own, not to the event
|
|
151
|
+
loop; `asyncio.to_thread` copies the context, so the audit's request id and
|
|
152
|
+
actor are the ones the handler sees.
|
|
153
|
+
"""
|
|
154
|
+
if inspect.iscoroutinefunction(handler):
|
|
155
|
+
return await handler(*args, **kwargs)
|
|
156
|
+
return await asyncio.to_thread(handler, *args, **kwargs)
|
|
157
|
+
|
|
158
|
+
|
|
136
159
|
def audited(action: str, method: str = "POST", actor: str = "current_user",
|
|
137
160
|
host: str = "framework"):
|
|
138
161
|
"""Record a framework route that the transport did not wrap (keepup-172).
|
|
@@ -160,7 +183,7 @@ def audited(action: str, method: str = "POST", actor: str = "current_user",
|
|
|
160
183
|
caller = kwargs.get(actor)
|
|
161
184
|
async with start_call(method, action, host, {}, actor=caller) as request_id:
|
|
162
185
|
try:
|
|
163
|
-
answer = await handler
|
|
186
|
+
answer = await _run_route(handler, *args, **kwargs)
|
|
164
187
|
except Exception as error:
|
|
165
188
|
await end_call(
|
|
166
189
|
request_id,
|
|
@@ -17,7 +17,7 @@ build-backend = "setuptools.build_meta"
|
|
|
17
17
|
|
|
18
18
|
[project]
|
|
19
19
|
name = "keepup-admin"
|
|
20
|
-
version = "0.7.
|
|
20
|
+
version = "0.7.1"
|
|
21
21
|
description = "An admin framework over FastAPI: plugins, panel, users, replicas"
|
|
22
22
|
readme = "README.md"
|
|
23
23
|
requires-python = ">=3.11"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|