Skip to content

Class tigrbl.session.abc.SessionABC

tigrbl.session.abc.SessionABC

Bases: ABC

Authoritative Tigrbl session interface.

All concrete sessions MUST be natively transactional and implement the methods below. This ABC is intentionally minimal and backend-agnostic.

begin abstractmethod async

begin()

Open a native transaction for this session.

Source code in tigrbl/session/abc.py
16
17
18
@abstractmethod
async def begin(self) -> None:
    """Open a native transaction for this session."""

commit abstractmethod async

commit()

Commit the current transaction.

Source code in tigrbl/session/abc.py
20
21
22
@abstractmethod
async def commit(self) -> None:
    """Commit the current transaction."""

rollback abstractmethod async

rollback()

Rollback the current transaction.

Source code in tigrbl/session/abc.py
24
25
26
@abstractmethod
async def rollback(self) -> None:
    """Rollback the current transaction."""

in_transaction abstractmethod

in_transaction()

Return True iff a transaction is currently open.

Source code in tigrbl/session/abc.py
28
29
30
@abstractmethod
def in_transaction(self) -> bool:
    """Return True iff a transaction is currently open."""

get abstractmethod async

get(model, ident)

Fetch one instance by primary key (model, ident).

Source code in tigrbl/session/abc.py
33
34
35
@abstractmethod
async def get(self, model: type, ident: Any) -> Any | None:
    """Fetch one instance by primary key (model, ident)."""

add abstractmethod

add(obj)

Stage a new/dirty object for persistence.

Source code in tigrbl/session/abc.py
37
38
39
@abstractmethod
def add(self, obj: Any) -> None:
    """Stage a new/dirty object for persistence."""

delete abstractmethod async

delete(obj)

Stage an object for deletion.

Source code in tigrbl/session/abc.py
41
42
43
@abstractmethod
async def delete(self, obj: Any) -> None:
    """Stage an object for deletion."""

flush abstractmethod async

flush()

Flush staged changes to the underlying store (still in TX).

Source code in tigrbl/session/abc.py
45
46
47
@abstractmethod
async def flush(self) -> None:
    """Flush staged changes to the underlying store (still in TX)."""

refresh abstractmethod async

refresh(obj)

Refresh the object from the store (respecting the current TX view).

Source code in tigrbl/session/abc.py
49
50
51
@abstractmethod
async def refresh(self, obj: Any) -> None:
    """Refresh the object from the store (respecting the current TX view)."""

execute abstractmethod async

execute(stmt)

Execute a backend-native statement.

The result (if any) SHOULD provide a minimal facade compatible with: - .scalars().all() - .scalar_one() to ease integration with higher-level helpers.

Source code in tigrbl/session/abc.py
53
54
55
56
57
58
59
60
61
62
@abstractmethod
async def execute(self, stmt: Any) -> Any:
    """
    Execute a backend-native statement.

    The result (if any) SHOULD provide a minimal facade compatible with:
      - .scalars().all()
      - .scalar_one()
    to ease integration with higher-level helpers.
    """

close abstractmethod async

close()

Release underlying resources (connections, cursors, etc.).

Source code in tigrbl/session/abc.py
65
66
67
@abstractmethod
async def close(self) -> None:
    """Release underlying resources (connections, cursors, etc.)."""

run_sync abstractmethod async

run_sync(fn)

Execute a callback against the underlying native handle.

Presence of this method also acts as the "async session" marker for code paths that need to distinguish sync-vs-async sessions.

Source code in tigrbl/session/abc.py
69
70
71
72
73
74
75
76
@abstractmethod
async def run_sync(self, fn: Callable[[Any], Any]) -> Any:
    """
    Execute a callback against the underlying native handle.

    Presence of this method also acts as the "async session" marker for code
    paths that need to distinguish sync-vs-async sessions.
    """