Added auth & improved database
All checks were successful
Build on push / prepare (push) Successful in 9s
Build on push / query (push) Successful in 18s
Build on push / core (push) Successful in 24s
Build on push / dependency (push) Successful in 17s
Build on push / database (push) Successful in 15s
Build on push / translation (push) Successful in 15s
Build on push / mail (push) Successful in 18s
Build on push / application (push) Successful in 19s
Build on push / auth (push) Successful in 16s

This commit is contained in:
2025-09-17 12:21:32 +02:00
parent 4625b626e6
commit 504dc5e188
76 changed files with 1849 additions and 302 deletions

View File

@@ -59,7 +59,7 @@ class ServiceProvider(ServiceProviderABC):
# raise Exception(f'Service {parameter.annotation} not found')
def _get_services(self, t: type, *args, service_type: type = None, **kwargs) -> list[Optional[object]]:
def _get_services(self, t: type, service_type: type = None, **kwargs) -> list[Optional[object]]:
implementations = []
for descriptor in self._service_descriptors:
if descriptor.service_type == t or issubclass(descriptor.service_type, t):
@@ -67,7 +67,9 @@ class ServiceProvider(ServiceProviderABC):
implementations.append(descriptor.implementation)
continue
implementation = self._build_service(descriptor.service_type, *args, service_type, **kwargs)
implementation = self._build_service(
descriptor.service_type, origin_service_type=service_type, **kwargs
)
if descriptor.lifetime == ServiceLifetimeEnum.singleton:
descriptor.implementation = implementation
@@ -93,7 +95,8 @@ class ServiceProvider(ServiceProviderABC):
params.append(Environment)
elif issubclass(parameter.annotation, ConfigurationModelABC):
params.append(Configuration.get(parameter.annotation))
conf = Configuration.get(parameter.annotation)
params.append(parameter.annotation() if conf is None else conf)
elif issubclass(parameter.annotation, Configuration):
params.append(Configuration)

View File

@@ -3,8 +3,8 @@ from abc import abstractmethod, ABC
from inspect import Signature, signature
from typing import Optional
from cpl.dependency.scope_abc import ScopeABC
from cpl.core.typing import T, R
from cpl.dependency.scope_abc import ScopeABC
class ServiceProviderABC(ABC):
@@ -24,6 +24,18 @@ class ServiceProviderABC(ABC):
def get_global_provider(cls) -> Optional["ServiceProviderABC"]:
return cls._provider
@classmethod
def get_global_service(cls, instance_type: T, *args, **kwargs) -> Optional[R]:
if cls._provider is None:
return None
return cls._provider.get_service(instance_type, *args, **kwargs)
@classmethod
def get_global_services(cls, instance_type: T, *args, **kwargs) -> list[Optional[R]]:
if cls._provider is None:
return []
return cls._provider.get_services(instance_type, *args, **kwargs)
@abstractmethod
def _build_by_signature(self, sig: Signature, origin_service_type: type) -> list[R]:
pass