Improved hosting

This commit is contained in:
2020-11-26 11:20:21 +01:00
parent 5faac76c32
commit ead0eae5f0
19 changed files with 124 additions and 37 deletions

View File

@@ -1,3 +1,4 @@
# imports:
from .application_host import ApplicationHost
from .hosting_environment import HostingEnvironment

View File

@@ -1,17 +1,29 @@
from datetime import datetime
from sh_edraft.hosting.base.application_host_base import ApplicationHostBase
from sh_edraft.hosting.base.environment_base import EnvironmentBase
from sh_edraft.service.service_provider import ServiceProvider
class ApplicationHost(ApplicationHostBase):
def __init__(self):
def __init__(self, name: str, env: EnvironmentBase):
ApplicationHostBase.__init__(self)
self._services = ServiceProvider()
self._name: str = name
self._environment: EnvironmentBase = env
self._services = ServiceProvider(self)
self._start_time: datetime = datetime.now()
self._end_time: datetime = datetime.now()
@property
def name(self) -> str:
return self._name
@property
def environment(self) -> EnvironmentBase:
return self._environment
@property
def services(self):
return self._services

View File

@@ -1,2 +1,3 @@
# imports:
from .application_host_base import ApplicationHostBase
from .environment_base import EnvironmentBase

View File

@@ -1,17 +1,28 @@
from abc import ABC, abstractmethod
from datetime import datetime
from sh_edraft.hosting.base.environment_base import EnvironmentBase
class ApplicationHostBase(ABC):
@abstractmethod
def __init__(self): pass
@property
@abstractmethod
def name(self) -> str: pass
@property
@abstractmethod
def environment(self) -> EnvironmentBase: pass
@property
@abstractmethod
def start_time(self) -> datetime: pass
@start_time.setter
@abstractmethod
def start_time(self, start_time: datetime): pass
@property
@@ -19,4 +30,9 @@ class ApplicationHostBase(ABC):
def end_time(self): pass
@end_time.setter
@abstractmethod
def end_time(self, end_time: datetime): pass
@property
@abstractmethod
def date_time_now(self) -> datetime: pass

View File

@@ -0,0 +1,25 @@
from abc import ABC, abstractmethod
from sh_edraft.hosting.model.environment_name import EnvironmentName
class EnvironmentBase(ABC):
@abstractmethod
def __init__(self): pass
@property
@abstractmethod
def name(self) -> EnvironmentName: pass
@name.setter
@abstractmethod
def name(self, name: EnvironmentName): pass
@property
@abstractmethod
def content_root_path(self) -> str: pass
@content_root_path.setter
@abstractmethod
def content_root_path(self, content_root_path: str): pass

View File

@@ -0,0 +1,20 @@
from sh_edraft.hosting.base.environment_base import EnvironmentBase
from sh_edraft.hosting.model.environment_name import EnvironmentName
class HostingEnvironment(EnvironmentBase):
def __init__(self, name: EnvironmentName, crp: str):
EnvironmentBase.__init__(self)
self._name = name
self._content_root_path = crp
@property
def name(self) -> EnvironmentName:
return self._name
@property
def content_root_path(self) -> str:
return self._content_root_path

View File

@@ -0,0 +1,2 @@
# imports:
from .environment_name import EnvironmentName

View File

@@ -0,0 +1,9 @@
from enum import Enum
class EnvironmentName(Enum):
production = 'production'
staging = 'staging'
testing = 'testing'
development = 'development'