Wsgi_15Watt.BaseTplController

 1from .BaseController import BaseController
 2
 3
 4class BaseTplController(BaseController):
 5	"""
 6		Basisklasse aller AdmController
 7	"""
 8	def __init__(self, config: dict):
 9		super().__init__(config=config)
10
11		if 'pathBase' in config:
12			self._pathBase = config['pathBase']
13		else:
14			raise ValueError('pathBase not found in config')
15
16		if 'pathTemplates' in config:
17			self._pathTemplates = config['pathTemplates']
18		else:
19			raise ValueError('pathTemplates not found in config')
20
21
22	def _loadTemplate(self, tplName: str) -> str:
23		"""
24			Lädt das Template
25		"""
26		strPath = self._pathTemplates + '/' + tplName
27		with open(strPath, 'r', encoding='utf-8') as file:
28			return file.read()
29
30
31	def render(self, request, response):
32		"""
33			Generiert das Template
34		"""
35		response.contentType = 'text/html'
36		response.returnCode = 200
37		response.stringContent = self._tpl
38		return
class BaseTplController(Wsgi_15Watt.BaseController.BaseController):
 5class BaseTplController(BaseController):
 6	"""
 7		Basisklasse aller AdmController
 8	"""
 9	def __init__(self, config: dict):
10		super().__init__(config=config)
11
12		if 'pathBase' in config:
13			self._pathBase = config['pathBase']
14		else:
15			raise ValueError('pathBase not found in config')
16
17		if 'pathTemplates' in config:
18			self._pathTemplates = config['pathTemplates']
19		else:
20			raise ValueError('pathTemplates not found in config')
21
22
23	def _loadTemplate(self, tplName: str) -> str:
24		"""
25			Lädt das Template
26		"""
27		strPath = self._pathTemplates + '/' + tplName
28		with open(strPath, 'r', encoding='utf-8') as file:
29			return file.read()
30
31
32	def render(self, request, response):
33		"""
34			Generiert das Template
35		"""
36		response.contentType = 'text/html'
37		response.returnCode = 200
38		response.stringContent = self._tpl
39		return

Basisklasse aller AdmController

BaseTplController(config: dict)
 9	def __init__(self, config: dict):
10		super().__init__(config=config)
11
12		if 'pathBase' in config:
13			self._pathBase = config['pathBase']
14		else:
15			raise ValueError('pathBase not found in config')
16
17		if 'pathTemplates' in config:
18			self._pathTemplates = config['pathTemplates']
19		else:
20			raise ValueError('pathTemplates not found in config')
def render(self, request, response):
32	def render(self, request, response):
33		"""
34			Generiert das Template
35		"""
36		response.contentType = 'text/html'
37		response.returnCode = 200
38		response.stringContent = self._tpl
39		return

Generiert das Template