Skip to content

Commit

Permalink
feat: inject profile and session
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bluhm <[email protected]>
  • Loading branch information
dbluhm committed May 29, 2024
1 parent 4b2625d commit 79e9c55
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions aries_cloudagent/core/profile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Classes for managing profile information within a request context."""

import logging
from abc import ABC, abstractmethod
import logging
from typing import Any, Mapping, Optional, Type
from weakref import ref

from ..config.base import InjectionError
from ..config.injection_context import InjectionContext
Expand Down Expand Up @@ -30,10 +31,16 @@ def __init__(
created: bool = False,
):
"""Initialize a base profile."""
self._context = context or InjectionContext()
self._created = created
self._name = name or Profile.DEFAULT_NAME

context = context or InjectionContext()
scope = "profile:" + self._name
if sub := context.settings.get("wallet.id"):
scope += ":" + sub
self._context = context.start_scope(scope)
self._context.injector.bind_instance(Profile, ref(self))

@property
def backend(self) -> str:
"""Accessor for the backend implementation name."""
Expand Down Expand Up @@ -163,6 +170,8 @@ def __init__(
self._profile = profile
self._events = []

self._context.injector.bind_instance(ProfileSession, ref(self))

async def _setup(self):
"""Create the underlying session or transaction."""

Expand Down

0 comments on commit 79e9c55

Please sign in to comment.