Merge pull request '2022.6.4' (#58) from 2022.6.4 into 2022.6

Reviewed-on: #58
This commit is contained in:
Sven Heidemann 2022-04-30 18:33:54 +02:00
commit 5b59d1d384
23 changed files with 116 additions and 49 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# activate venv # activate venv
source /home/sven/Nextcloud_Sven/Schreibtisch/git_sh-edraft_de/sh_cpl/cpl-env/bin/activate source /home/sven/Nextcloud_Sven/Schreibtisch/git_sh-edraft_de/sh_cpl/venv/bin/activate
# CPL # CPL
cd /home/sven/Nextcloud_Sven/Schreibtisch/git_sh-edraft_de/sh_cpl/src/cpl_core cd /home/sven/Nextcloud_Sven/Schreibtisch/git_sh-edraft_de/sh_cpl/src/cpl_core

View File

@ -16,7 +16,7 @@
"LicenseName": "MIT", "LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.", "LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [ "Dependencies": [
"cpl-core>=2022.6.1" "cpl-core>=2022.6.2"
], ],
"PythonVersion": ">=3.10", "PythonVersion": ">=3.10",
"PythonPath": {}, "PythonPath": {},

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_core'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.1' __version__ = '2022.6.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='1') version_info = VersionInfo(major='2022', minor='6', micro='2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.application'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.1' __version__ = '2022.6.2'
from collections import namedtuple from collections import namedtuple
@ -24,6 +24,7 @@ from .application_abc import ApplicationABC
from .application_builder import ApplicationBuilder from .application_builder import ApplicationBuilder
from .application_builder_abc import ApplicationBuilderABC from .application_builder_abc import ApplicationBuilderABC
from .startup_abc import StartupABC from .startup_abc import StartupABC
from .startup_extension_abc import StartupExtensionABC
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='1') version_info = VersionInfo(major='2022', minor='6', micro='2')

View File

@ -1,9 +1,10 @@
from typing import Type, Optional, Callable from typing import Type, Optional, Callable, Union
from cpl_core.application.application_abc import ApplicationABC from cpl_core.application.application_abc import ApplicationABC
from cpl_core.application.application_builder_abc import ApplicationBuilderABC from cpl_core.application.application_builder_abc import ApplicationBuilderABC
from cpl_core.application.application_extension_abc import ApplicationExtensionABC from cpl_core.application.application_extension_abc import ApplicationExtensionABC
from cpl_core.application.startup_abc import StartupABC from cpl_core.application.startup_abc import StartupABC
from cpl_core.application.startup_extension_abc import StartupExtensionABC
from cpl_core.configuration.configuration import Configuration from cpl_core.configuration.configuration import Configuration
from cpl_core.dependency_injection.service_collection import ServiceCollection from cpl_core.dependency_injection.service_collection import ServiceCollection
@ -26,38 +27,47 @@ class ApplicationBuilder(ApplicationBuilderABC):
self._environment = self._configuration.environment self._environment = self._configuration.environment
self._services = ServiceCollection(self._configuration) self._services = ServiceCollection(self._configuration)
self._extensions: list[Callable] = [] self._app_extensions: list[Callable] = []
self._startup_extensions: list[Callable] = []
def use_startup(self, startup: Type[StartupABC]): def use_startup(self, startup: Type[StartupABC]):
self._startup = startup() self._startup = startup()
def use_extension(self, extension: Type[ApplicationExtensionABC]): def use_extension(self, extension: Type[Union[ApplicationExtensionABC, StartupExtensionABC]]):
if extension not in self._extensions: if issubclass(extension, ApplicationExtensionABC) and extension not in self._app_extensions:
self._extensions.append(extension) self._app_extensions.append(extension)
elif issubclass(extension, StartupExtensionABC) and extension not in self._startup_extensions:
self._startup_extensions.append(extension)
def _build_startup(self):
for ex in self._startup_extensions:
extension = ex()
extension.configure_configuration(self._configuration, self._environment)
extension.configure_services(self._services, self._environment)
def build(self) -> ApplicationABC:
if self._startup is not None: if self._startup is not None:
self._startup.configure_configuration(self._configuration, self._environment) self._startup.configure_configuration(self._configuration, self._environment)
self._startup.configure_services(self._services, self._environment) self._startup.configure_services(self._services, self._environment)
def build(self) -> ApplicationABC:
self._build_startup()
config = self._configuration config = self._configuration
services = self._services.build_service_provider() services = self._services.build_service_provider()
for ex in self._extensions: for ex in self._app_extensions:
extension = ex() extension = ex()
extension.run(config, services) extension.run(config, services)
return self._app(config, services) return self._app(config, services)
async def build_async(self) -> ApplicationABC: async def build_async(self) -> ApplicationABC:
if self._startup is not None: self._build_startup()
await self._startup.configure_configuration(self._configuration, self._environment)
await self._startup.configure_services(self._services, self._environment)
config = self._configuration config = self._configuration
services = self._services.build_service_provider() services = self._services.build_service_provider()
for ex in self._extensions: for ex in self._app_extensions:
extension = ex() extension = ex()
await extension.run(config, services) await extension.run(config, services)

View File

@ -10,8 +10,7 @@ class StartupABC(ABC):
r"""ABC for the startup class""" r"""ABC for the startup class"""
@abstractmethod @abstractmethod
def __init__(self, *args): def __init__(self): pass
pass
@abstractmethod @abstractmethod
def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC) -> ConfigurationABC: def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC) -> ConfigurationABC:

View File

@ -0,0 +1,34 @@
from abc import ABC, abstractmethod
from cpl_core.configuration.configuration_abc import ConfigurationABC
from cpl_core.dependency_injection.service_collection_abc import ServiceCollectionABC
from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC
class StartupExtensionABC(ABC):
r"""ABC for startup extension classes"""
@abstractmethod
def __init__(self): pass
@abstractmethod
def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC):
r"""Creates configuration of application
Parameter
---------
config: :class:`cpl_core.configuration.configuration_abc.ConfigurationABC`
env: :class:`cpl_core.environment.application_environment_abc`
"""
pass
@abstractmethod
def configure_services(self, service: ServiceCollectionABC, env: ApplicationEnvironmentABC):
r"""Creates service provider
Parameter
---------
services: :class:`cpl_core.dependency_injection.service_collection_abc`
env: :class:`cpl_core.environment.application_environment_abc`
"""
pass

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.configuration'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.1' __version__ = '2022.6.2'
from collections import namedtuple from collections import namedtuple
@ -27,4 +27,4 @@ from .configuration_variable_name_enum import ConfigurationVariableNameEnum
from .console_argument import ConsoleArgument from .console_argument import ConsoleArgument
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='1') version_info = VersionInfo(major='2022', minor='6', micro='2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.console'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.1' __version__ = '2022.6.2'
from collections import namedtuple from collections import namedtuple
@ -27,4 +27,4 @@ from .foreground_color_enum import ForegroundColorEnum
from .spinner_thread import SpinnerThread from .spinner_thread import SpinnerThread
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='1') version_info = VersionInfo(major='2022', minor='6', micro='2')

View File

@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "2022", "Major": "2022",
"Minor": "6", "Minor": "6",
"Micro": "1" "Micro": "2"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.database'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.1' __version__ = '2022.6.2'
from collections import namedtuple from collections import namedtuple
@ -25,4 +25,4 @@ from .database_settings import DatabaseSettings
from .table_abc import TableABC from .table_abc import TableABC
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='1') version_info = VersionInfo(major='2022', minor='6', micro='2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.database.connection'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.1' __version__ = '2022.6.2'
from collections import namedtuple from collections import namedtuple
@ -24,4 +24,4 @@ from .database_connection import DatabaseConnection
from .database_connection_abc import DatabaseConnectionABC from .database_connection_abc import DatabaseConnectionABC
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='1') version_info = VersionInfo(major='2022', minor='6', micro='2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.database.context'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.1' __version__ = '2022.6.2'
from collections import namedtuple from collections import namedtuple
@ -24,4 +24,4 @@ from .database_context import DatabaseContext
from .database_context_abc import DatabaseContextABC from .database_context_abc import DatabaseContextABC
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='1') version_info = VersionInfo(major='2022', minor='6', micro='2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.dependency_injection'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.1' __version__ = '2022.6.2'
from collections import namedtuple from collections import namedtuple
@ -28,4 +28,4 @@ from .service_provider import ServiceProvider
from .service_provider_abc import ServiceProviderABC from .service_provider_abc import ServiceProviderABC
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='1') version_info = VersionInfo(major='2022', minor='6', micro='2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.environment'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.1' __version__ = '2022.6.2'
from collections import namedtuple from collections import namedtuple
@ -25,4 +25,4 @@ from .environment_name_enum import EnvironmentNameEnum
from .application_environment import ApplicationEnvironment from .application_environment import ApplicationEnvironment
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='1') version_info = VersionInfo(major='2022', minor='6', micro='2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.logging'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.1' __version__ = '2022.6.2'
from collections import namedtuple from collections import namedtuple
@ -27,4 +27,4 @@ from .logging_settings import LoggingSettings
from .logging_settings_name_enum import LoggingSettingsNameEnum from .logging_settings_name_enum import LoggingSettingsNameEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='1') version_info = VersionInfo(major='2022', minor='6', micro='2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.mailing'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.1' __version__ = '2022.6.2'
from collections import namedtuple from collections import namedtuple
@ -27,4 +27,4 @@ from .email_client_settings import EMailClientSettings
from .email_client_settings_name_enum import EMailClientSettingsNameEnum from .email_client_settings_name_enum import EMailClientSettingsNameEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='1') version_info = VersionInfo(major='2022', minor='6', micro='2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.time'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.1' __version__ = '2022.6.2'
from collections import namedtuple from collections import namedtuple
@ -24,4 +24,4 @@ from .time_format_settings import TimeFormatSettings
from .time_format_settings_names_enum import TimeFormatSettingsNamesEnum from .time_format_settings_names_enum import TimeFormatSettingsNamesEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='1') version_info = VersionInfo(major='2022', minor='6', micro='2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.utils'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.1' __version__ = '2022.6.2'
from collections import namedtuple from collections import namedtuple
@ -25,4 +25,4 @@ from .string import String
from .pip import Pip from .pip import Pip
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='1') version_info = VersionInfo(major='2022', minor='6', micro='2')

View File

@ -21,9 +21,13 @@
}, },
"DatabaseSettings": { "DatabaseSettings": {
"AuthPlugin": "mysql_native_password", "Host": "localhost",
"ConnectionString": "mysql+mysqlconnector://sh_cpl:$credentials@localhost/sh_cpl", "User": "sh_cpl",
"Credentials": "MHZhc0Y2bjhKc1VUMWV0Qw==", "Password": "MHZhc0Y2bjhKc1VUMWV0Qw==",
"Encoding": "utf8mb4" "Database": "sh_cpl",
"Charset": "utf8mb4",
"UseUnicode": "true",
"Buffered": "true",
"AuthPlugin": "mysql_native_password"
} }
} }

View File

@ -16,9 +16,9 @@
"LicenseName": "MIT", "LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.", "LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [ "Dependencies": [
"sh_cpl==2021.4.0.post2" "cpl_core==2022.6.1"
], ],
"PythonVersion": ">=3.8", "PythonVersion": ">=3.10",
"PythonPath": { "PythonPath": {
"linux": "../../../../../../cpl-env/bin/python3.9", "linux": "../../../../../../cpl-env/bin/python3.9",
"win32": "" "win32": ""

View File

@ -1,12 +1,14 @@
from application import Application from application import Application
from cpl_core.application import ApplicationBuilder from cpl_core.application import ApplicationBuilder
from general.test_extension import TestExtension from test_extension import TestExtension
from startup import Startup from startup import Startup
from test_startup_extension import TestStartupExtension
def main(): def main():
app_builder = ApplicationBuilder(Application) app_builder = ApplicationBuilder(Application)
app_builder.use_startup(Startup) app_builder.use_startup(Startup)
app_builder.use_extension(TestStartupExtension)
app_builder.use_extension(TestExtension) app_builder.use_extension(TestExtension)
app_builder.build().run() app_builder.build().run()

View File

@ -0,0 +1,17 @@
from cpl_core.application import StartupExtensionABC
from cpl_core.configuration import ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceCollectionABC
from cpl_core.environment import ApplicationEnvironmentABC
class TestStartupExtension(StartupExtensionABC):
def __init__(self):
StartupExtensionABC.__init__(self)
def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC):
Console.write_line('config')
def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC):
Console.write_line('services')