[docs]classContainer(BaseContainer):"""Override's rodi container with our way to load services. This is a working implementation, although it would need polishing. Maybe the container should be reworked entirely to avoid the rodi duplications entirely, here the api methods using the builtin rodi providers/resolvers are still available, and that's maybe not what we want, for the long term."""
[docs]defload(self,filename,*,bind_settings):""" Loads a declarative service collection from a yaml file, and bind settings for config resolution. :param filename: str :param bind_settings: dict-like """from.resolversimportServiceResolvercollection=ServiceDefinitionCollection.model_validate_yaml(filename)ifbind_settings:collection.bind_settings(bind_settings)forserviceincollection:lifestyle=getattr(ServiceLifeStyle,(service.lifestyleor"singleton").upper())resolver=ServiceResolver(self,service,lifestyle)ifresolver.base_typeinself._map:raiseOverridingServiceException(resolver.base_type,resolver)self._map[resolver.base_type]=resolverifservice.nameinself._exact_aliases:raiseOverridingServiceException(service.name,resolver.base_type)self.set_alias(service.name,resolver.base_type)