tigrbl-base 0.4.3.dev4__tar.gz → 0.4.4.dev7__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.
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/PKG-INFO +1 -1
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/pyproject.toml +1 -1
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/__init__.py +2 -0
- tigrbl_base-0.4.4.dev7/tigrbl_base/_base/_headers_base.py +85 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_response_base.py +4 -11
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_schema_base.py +33 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_table_base.py +5 -0
- tigrbl_base-0.4.3.dev4/tigrbl_base/_base/_headers_base.py +0 -12
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/LICENSE +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/NOTICE +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/README.md +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_alias_base.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_app_base.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_assembly.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_binding_base.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_column_base.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_datatype_lowering.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_engine_base.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_engine_provider_base.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_hook_base.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_mapping_access.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_middleware_base.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_op_base.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_request_base.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_rest_map.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_router_base.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_rpc_map.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_security_base.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_session_abc.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_session_base.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_storage.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_table_registry_base.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/column/__init__.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/column/infer/__init__.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/column/infer/core.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/column/infer/jsonhints.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/column/infer/planning.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/column/infer/types.py +0 -0
- {tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/column/infer/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tigrbl-base
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.4.dev7
|
|
4
4
|
Summary: Base contract package for Tigrbl apps, routers, tables, sessions, middleware, requests, responses, bindings, and engine interfaces.
|
|
5
5
|
License: Apache License
|
|
6
6
|
Version 2.0, January 2004
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "tigrbl-base"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.4.dev7"
|
|
4
4
|
description = "Base contract package for Tigrbl apps, routers, tables, sessions, middleware, requests, responses, bindings, and engine interfaces."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = { file = "LICENSE" }
|
|
@@ -13,6 +13,8 @@ _EXPORTS = {
|
|
|
13
13
|
"AliasBase": "_alias_base",
|
|
14
14
|
"EngineBase": "_engine_base",
|
|
15
15
|
"EngineProviderBase": "_engine_provider_base",
|
|
16
|
+
"HeaderCookiesBase": "_headers_base",
|
|
17
|
+
"HeadersBase": "_headers_base",
|
|
16
18
|
"HookBase": "_hook_base",
|
|
17
19
|
"RouterBase": "_router_base",
|
|
18
20
|
"ForeignKeyBase": "_storage",
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Iterable, Mapping
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from tigrbl_core._spec.headers_spec import HeadersSpec
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
HeaderInput = Iterable[tuple[str, str]] | Mapping[str, str] | HeadersSpec | None
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _normalize_header_name(name: Any) -> str:
|
|
13
|
+
if isinstance(name, (bytes, bytearray)):
|
|
14
|
+
return name.decode("latin-1").lower()
|
|
15
|
+
return str(name).lower()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _normalize_header_value(value: Any) -> str:
|
|
19
|
+
if isinstance(value, (bytes, bytearray)):
|
|
20
|
+
return value.decode("latin-1")
|
|
21
|
+
return str(value)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _iter_header_items(values: HeaderInput):
|
|
25
|
+
if values is None:
|
|
26
|
+
return ()
|
|
27
|
+
if isinstance(values, HeadersSpec):
|
|
28
|
+
return values.values.items()
|
|
29
|
+
if hasattr(values, "items"):
|
|
30
|
+
return values.items() # type: ignore[union-attr]
|
|
31
|
+
return values
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class HeadersBase(dict[str, str]):
|
|
35
|
+
"""Base header mapping type for response implementations."""
|
|
36
|
+
|
|
37
|
+
required: tuple[str, ...]
|
|
38
|
+
expose: tuple[str, ...]
|
|
39
|
+
|
|
40
|
+
def __init__(
|
|
41
|
+
self,
|
|
42
|
+
values: HeaderInput = None,
|
|
43
|
+
*,
|
|
44
|
+
required: tuple[str, ...] = (),
|
|
45
|
+
expose: tuple[str, ...] = (),
|
|
46
|
+
) -> None:
|
|
47
|
+
if isinstance(values, HeadersSpec):
|
|
48
|
+
required = values.required
|
|
49
|
+
expose = values.expose
|
|
50
|
+
super().__init__(
|
|
51
|
+
{
|
|
52
|
+
_normalize_header_name(key): _normalize_header_value(value)
|
|
53
|
+
for key, value in _iter_header_items(values)
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
self.required = tuple(_normalize_header_name(name) for name in required)
|
|
57
|
+
self.expose = tuple(_normalize_header_name(name) for name in expose)
|
|
58
|
+
|
|
59
|
+
def __getitem__(self, key: str) -> str:
|
|
60
|
+
return super().__getitem__(_normalize_header_name(key))
|
|
61
|
+
|
|
62
|
+
def __contains__(self, key: object) -> bool:
|
|
63
|
+
if isinstance(key, (str, bytes, bytearray)):
|
|
64
|
+
return super().__contains__(_normalize_header_name(key))
|
|
65
|
+
return super().__contains__(key)
|
|
66
|
+
|
|
67
|
+
def get(self, key: str, default: Any = None) -> str | Any:
|
|
68
|
+
return super().get(_normalize_header_name(key), default)
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def raw_headers(self) -> list[tuple[bytes, bytes]]:
|
|
72
|
+
return [
|
|
73
|
+
(key.encode("latin-1"), value.encode("latin-1"))
|
|
74
|
+
for key, value in self.items()
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
def as_spec(self) -> HeadersSpec:
|
|
78
|
+
return HeadersSpec(values=dict(self), required=self.required, expose=self.expose)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class HeaderCookiesBase(dict[str, str]):
|
|
82
|
+
"""Base cookie mapping type for response implementations."""
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
__all__ = ["HeaderCookiesBase", "HeadersBase"]
|
|
@@ -38,18 +38,13 @@ class ResponseBase(ResponseSpec):
|
|
|
38
38
|
payload = (
|
|
39
39
|
body if body is not None else (content if content is not None else b"")
|
|
40
40
|
)
|
|
41
|
-
|
|
42
|
-
str(key).lower(): str(value)
|
|
43
|
-
for key, value in (
|
|
44
|
-
headers.items() if hasattr(headers, "items") else (headers or [])
|
|
45
|
-
)
|
|
46
|
-
}
|
|
41
|
+
headers_base = HeadersBase(headers)
|
|
47
42
|
|
|
48
43
|
super().__init__(
|
|
49
44
|
kind=kind,
|
|
50
45
|
media_type=media_type,
|
|
51
46
|
status_code=status_code,
|
|
52
|
-
headers=dict(
|
|
47
|
+
headers=dict(headers_base),
|
|
53
48
|
envelope=envelope,
|
|
54
49
|
template=template,
|
|
55
50
|
filename=filename,
|
|
@@ -59,15 +54,13 @@ class ResponseBase(ResponseSpec):
|
|
|
59
54
|
redirect_to=redirect_to,
|
|
60
55
|
)
|
|
61
56
|
self.status_code = status_code
|
|
62
|
-
self.headers: HeadersBase =
|
|
57
|
+
self.headers: HeadersBase = headers_base
|
|
63
58
|
self.body = payload
|
|
64
59
|
self.media_type = media_type
|
|
65
60
|
|
|
66
61
|
@property
|
|
67
62
|
def raw_headers(self) -> list[tuple[bytes, bytes]]:
|
|
68
|
-
return
|
|
69
|
-
(k.encode("latin-1"), v.encode("latin-1")) for k, v in self.headers.items()
|
|
70
|
-
]
|
|
63
|
+
return self.headers.raw_headers
|
|
71
64
|
|
|
72
65
|
@property
|
|
73
66
|
def headers_map(self) -> HeadersBase:
|
|
@@ -9,6 +9,39 @@ from tigrbl_core.config.constants import TIGRBL_SCHEMA_DECLS_ATTR
|
|
|
9
9
|
class SchemaBase:
|
|
10
10
|
"""Shared schema helpers used by concrete schema wrappers."""
|
|
11
11
|
|
|
12
|
+
@staticmethod
|
|
13
|
+
def bind_declared_schema(
|
|
14
|
+
model: type, alias: str, kind: str, schema_cls: type
|
|
15
|
+
) -> None:
|
|
16
|
+
"""Expose a declared schema on ``model.schemas.<alias>`` immediately."""
|
|
17
|
+
|
|
18
|
+
if kind not in ("in", "out"):
|
|
19
|
+
raise ValueError("schema_ctx(kind=...) must be 'in' or 'out'")
|
|
20
|
+
|
|
21
|
+
schemas = getattr(model, "schemas", None)
|
|
22
|
+
if not isinstance(schemas, SimpleNamespace):
|
|
23
|
+
schemas = SimpleNamespace()
|
|
24
|
+
setattr(model, "schemas", schemas)
|
|
25
|
+
|
|
26
|
+
alias_ns = getattr(schemas, alias, None)
|
|
27
|
+
if not isinstance(alias_ns, SimpleNamespace):
|
|
28
|
+
alias_ns = SimpleNamespace()
|
|
29
|
+
setattr(schemas, alias, alias_ns)
|
|
30
|
+
|
|
31
|
+
setattr(alias_ns, "in_" if kind == "in" else "out", schema_cls)
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def bind_nested_declarations(cls, model: type) -> None:
|
|
35
|
+
"""Bind nested ``schema_ctx`` declarations onto a table/model class."""
|
|
36
|
+
|
|
37
|
+
for obj in tuple(model.__dict__.values()):
|
|
38
|
+
if not inspect.isclass(obj):
|
|
39
|
+
continue
|
|
40
|
+
decl = getattr(obj, "__tigrbl_schema_decl__", None)
|
|
41
|
+
if decl is None:
|
|
42
|
+
continue
|
|
43
|
+
cls.bind_declared_schema(model, decl.alias, decl.kind, obj)
|
|
44
|
+
|
|
12
45
|
@classmethod
|
|
13
46
|
def collect(cls, model: type) -> dict[str, dict[str, type]]:
|
|
14
47
|
"""Collect schema declarations from explicit mappings and decorator metadata."""
|
|
@@ -18,6 +18,7 @@ from tigrbl_core._spec.table_profile_spec import (
|
|
|
18
18
|
TableProfileError,
|
|
19
19
|
coerce_table_profile,
|
|
20
20
|
)
|
|
21
|
+
from ._schema_base import SchemaBase
|
|
21
22
|
|
|
22
23
|
# ──────────────────────────────────────────────────────────────────────────────
|
|
23
24
|
# Helpers – type inference & SA type instantiation
|
|
@@ -521,6 +522,10 @@ class TableBase(DeclarativeBase):
|
|
|
521
522
|
# 2) Let SQLAlchemy map the class (PK now exists)
|
|
522
523
|
super().__init_subclass__(**kw)
|
|
523
524
|
|
|
525
|
+
# 2.3) Surface table-local schema_ctx declarations immediately without
|
|
526
|
+
# invoking full schema synthesis or runtime binding.
|
|
527
|
+
SchemaBase.bind_nested_declarations(cls)
|
|
528
|
+
|
|
524
529
|
# 2.5) Surface ctx-only op declarations for lightweight introspection.
|
|
525
530
|
has_decorated_ops = False
|
|
526
531
|
if not hasattr(cls, "__tigrbl_ops__"):
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class HeadersBase(dict[str, str]):
|
|
5
|
-
"""Base header mapping type for response implementations."""
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class HeaderCookiesBase(dict[str, str]):
|
|
9
|
-
"""Base cookie mapping type for response implementations."""
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
__all__ = ["HeaderCookiesBase", "HeadersBase"]
|
|
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
|
{tigrbl_base-0.4.3.dev4 → tigrbl_base-0.4.4.dev7}/tigrbl_base/_base/_engine_provider_base.py
RENAMED
|
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
|