Improved hosting
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
# imports:
|
||||
|
||||
from .application_host import ApplicationHost
|
||||
from .hosting_environment import HostingEnvironment
|
||||
|
@@ -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
|
||||
|
@@ -1,2 +1,3 @@
|
||||
# imports:
|
||||
from .application_host_base import ApplicationHostBase
|
||||
from .environment_base import EnvironmentBase
|
||||
|
@@ -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
|
||||
|
25
src/sh_edraft/hosting/base/environment_base.py
Normal file
25
src/sh_edraft/hosting/base/environment_base.py
Normal 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
|
20
src/sh_edraft/hosting/hosting_environment.py
Normal file
20
src/sh_edraft/hosting/hosting_environment.py
Normal 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
|
||||
|
@@ -0,0 +1,2 @@
|
||||
# imports:
|
||||
from .environment_name import EnvironmentName
|
9
src/sh_edraft/hosting/model/environment_name.py
Normal file
9
src/sh_edraft/hosting/model/environment_name.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class EnvironmentName(Enum):
|
||||
|
||||
production = 'production'
|
||||
staging = 'staging'
|
||||
testing = 'testing'
|
||||
development = 'development'
|
Reference in New Issue
Block a user