Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def current_session() -> AbsMetaSession:
"""Get/create :class:`.AbsMetaSession` for this context."""
g = get_application_global()
if not g:
return get_session()
if 'abs_meta' not in g:
g.abs_meta = get_session()
assert isinstance(g.abs_meta, AbsMetaSession)
return g.abs_meta
def current_session() -> DocumentCacheSession:
"""Get/create :class:`.DocumentCacheSession` for this context."""
g = get_application_global()
if not g:
return get_session()
if 'doc_cache' not in g:
g.doc_cache = get_session()
assert isinstance(g.doc_cache, DocumentCacheSession)
return g.doc_cache