MCPcopy
hub / github.com/dataelement/Clawith / session

Method session

backend/app/dao/base.py:20–37  ·  view source on GitHub ↗

Context manager yielding the active context session or a new one.

(self)

Source from the content-addressed store, hash-verified

18
19 @asynccontextmanager
20 async def session(self) -> AsyncGenerator[AsyncSession, None]:
21 """Context manager yielding the active context session or a new one."""
22 context_session = _session_ctx.get()
23 if context_session is not None:
24 yield context_session
25 else:
26 async with async_session() as session:
27 token = _session_ctx.set(session)
28 try:
29 yield session
30 if hasattr(session, "commit"):
31 await session.commit()
32 except Exception:
33 if hasattr(session, "rollback"):
34 await session.rollback()
35 raise
36 finally:
37 _session_ctx.reset(token)
38
39 async def get(self, id: Any) -> ModelType | None:
40 """Fetch a single record by its primary key ID."""

Callers 15

getMethod · 0.95
is_emptyMethod · 0.95
get_allMethod · 0.95
createMethod · 0.95
updateMethod · 0.95
deleteMethod · 0.95
register_with_ssoMethod · 0.80
bind_org_memberMethod · 0.80
ensure_web_org_memberMethod · 0.80

Calls 3

rollbackMethod · 0.80
getMethod · 0.45
commitMethod · 0.45