Skip to content
Snippets Groups Projects
Commit b4872969 authored by Sebastian Lobinger's avatar Sebastian Lobinger
Browse files

update sams_classes/sams_hub.py to pass test_context_processor_app_lang

parent 2e403ea8
No related branches found
No related tags found
No related merge requests found
from flask import Flask
from flask import Flask, request
from .exceptions import (
ManifestDefaultLanguageMissing
, DefaultLanguageDictMissing
......@@ -15,11 +15,13 @@ from .exceptions import FunctionNotExists
class SAMSHub:
def __init__(self, name: str, config: dict):
if not config.get('default_language'):
self._config = config;
if not self._config.get('default_language'):
raise TypeError(
'Parameter config musst contain a value for "default_language"')
self._apps = {}
self._flaskApp = Flask(name)
self._flaskApp.context_processor(self._context_processor)
def addApp(self, app: SAMSApp = None):
if not isinstance(app, SAMSApp):
......@@ -52,6 +54,13 @@ class SAMSHub:
self.__blueprints[module].add_url_rule(rule = rule, endpoint = endpoint
, view_func = view_func)
def _context_processor(self):
return {
'app_lang': self.app(
request.blueprint).lang(self._config['default_language']
)
}
@staticmethod
def _get_module_rule(module, path):
pathElements = [module]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment