Merge pull request '2022.10.4 - Removed async from startup functions (#94)' (#110) from 2022.10.4 into 2022.10
Reviewed-on: #110 Closes #94
This commit is contained in:
commit
f23d32a92a
@ -5,51 +5,30 @@ from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
class StartupTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str, use_async: bool):
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = 'startup.py'
|
||||
self._path = path
|
||||
self._use_async = use_async
|
||||
|
||||
if self._use_async:
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl_core.application import StartupABC
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||
from cpl_core.environment import ApplicationEnvironment
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl_core.application import StartupABC
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||
from cpl_core.environment import ApplicationEnvironment
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
class Startup(StartupABC):
|
||||
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||
return configuration
|
||||
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||
return configuration
|
||||
|
||||
async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
||||
return services.build_service_provider()
|
||||
""")
|
||||
else:
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl_core.application import StartupABC
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||
from cpl_core.environment import ApplicationEnvironment
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||
return configuration
|
||||
|
||||
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
||||
return services.build_service_provider()
|
||||
""")
|
||||
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
||||
return services.build_service_provider()
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
|
@ -5,50 +5,29 @@ from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
class StartupTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str, use_async: bool):
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = 'startup.py'
|
||||
self._path = path
|
||||
|
||||
if use_async:
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl_core.application import StartupABC
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||
from cpl_core.environment import ApplicationEnvironment
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl_core.application import StartupABC
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||
from cpl_core.environment import ApplicationEnvironment
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
class Startup(StartupABC):
|
||||
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||
return configuration
|
||||
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||
return configuration
|
||||
|
||||
async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
||||
return services.build_service_provider()
|
||||
""")
|
||||
else:
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl_core.application import StartupABC
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||
from cpl_core.environment import ApplicationEnvironment
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||
return configuration
|
||||
|
||||
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
||||
return services.build_service_provider()
|
||||
""")
|
||||
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
||||
return services.build_service_provider()
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
|
@ -109,7 +109,7 @@ class ConsoleBuilder:
|
||||
templates.append(ApplicationTemplate(src_name, py_src_rel_path, use_async))
|
||||
|
||||
if use_startup:
|
||||
templates.append(StartupTemplate(src_name, py_src_rel_path, use_async))
|
||||
templates.append(StartupTemplate(src_name, py_src_rel_path))
|
||||
templates.append(MainWithApplicationHostAndStartupTemplate(src_name, py_src_rel_path, use_async))
|
||||
else:
|
||||
templates.append(MainWithApplicationBaseTemplate(src_name, py_src_rel_path, use_async))
|
||||
|
@ -113,7 +113,7 @@ class LibraryBuilder:
|
||||
templates.append(ApplicationTemplate(src_name, py_src_rel_path, use_async))
|
||||
|
||||
if use_startup:
|
||||
templates.append(StartupTemplate(src_name, py_src_rel_path, use_async))
|
||||
templates.append(StartupTemplate(src_name, py_src_rel_path))
|
||||
templates.append(MainWithApplicationHostAndStartupTemplate(src_name, py_src_rel_path, use_async))
|
||||
else:
|
||||
templates.append(MainWithApplicationBaseTemplate(src_name, py_src_rel_path, use_async))
|
||||
|
Loading…
Reference in New Issue
Block a user