Class tigrbl.runtime.context.Context
tigrbl.runtime.context.Context
dataclass
Context(
op,
persist,
specs,
cfg,
temp=dict(),
model=None,
obj=None,
session=None,
user=None,
tenant=None,
now=None,
row=None,
values=None,
current_values=None,
in_data=None,
payload=None,
data=None,
body=None,
)
Canonical runtime context shared by the kernel and atoms.
Minimal contract (consumed by atoms we’ve written so far): - op: operation name (e.g., 'create' | 'update' | 'read' | 'list' | custom) - persist: write vs. read (affects pruning of persist-tied anchors) - specs: mapping of field -> ColumnSpec (frozen at bind time) - cfg: read-only config view (see config.resolver.CfgView) - temp: dict scratchpad used by atoms to exchange data
Optional adapter slots
- model: owning model type / class
- obj: hydrated ORM instance (if any)
- session: DB session / unit-of-work handle
- user, tenant, now: identity/time hints
- row/values/current_values: mapping fallbacks (for read paths)
- in_data / payload / data / body: inbound payload staging (for build_in)
op
instance-attribute
op
persist
instance-attribute
persist
specs
instance-attribute
specs
cfg
instance-attribute
cfg
temp
class-attribute
instance-attribute
temp = field(default_factory=dict)
model
class-attribute
instance-attribute
model = None
obj
class-attribute
instance-attribute
obj = None
session
class-attribute
instance-attribute
session = None
user
class-attribute
instance-attribute
user = None
tenant
class-attribute
instance-attribute
tenant = None
now
class-attribute
instance-attribute
now = None
row
class-attribute
instance-attribute
row = None
values
class-attribute
instance-attribute
values = None
current_values
class-attribute
instance-attribute
current_values = None
in_data
class-attribute
instance-attribute
in_data = None
payload
class-attribute
instance-attribute
payload = None
data
class-attribute
instance-attribute
data = None
body
class-attribute
instance-attribute
body = None
is_write
property
is_write
Alias for persist; reads better in some call sites.
safe_view
safe_view(*, include_temp=False, temp_keys=None)
Return a small, read-only mapping exposing only safe, frequently useful keys.
By default, temp is NOT included (to avoid leaking internals like paired raw values). If include_temp=True, only exposes the keys listed in 'temp_keys' (if provided), otherwise exposes a conservative subset.
This method is intended to be passed into author callables such as default_factory(ctx_view) or paired token generators.
Source code in tigrbl/runtime/context.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
mark_used_returning
mark_used_returning(value=True)
Flag that DB RETURNING already hydrated values.
Source code in tigrbl/runtime/context.py
122 123 124 |
|
merge_hydrated_values
merge_hydrated_values(mapping, *, replace=False)
Save values hydrated from DB (RETURNING/refresh). If replace=False (default), performs a shallow merge into any existing 'hydrated_values'.
Source code in tigrbl/runtime/context.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
add_response_extras
add_response_extras(extras, *, overwrite=None)
Merge alias extras into temp['response_extras']. Returns a tuple of conflicting keys that were skipped when overwrite=False.
Source code in tigrbl/runtime/context.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
get_response_payload
get_response_payload()
Return the payload assembled by wire:dump (or None if not yet available).
Source code in tigrbl/runtime/context.py
165 166 167 |
|