Source code for luna_python_matcher.app_common.handlers.base_handler

# -*- coding: utf-8 -*-
""" Base handler

Module realize base class for all handlers.
"""

from typing import Union

from app.app import PythonMatcherApp
from app_proxy.app import PythonMatcherProxyApp
from configs.configs.configs.services.matcher_proxy import SettingsPythonMatcherProxy
from configs.configs.configs.services.python_matcher import SettingsPythonMatcher
from crutches_on_wheels.web.handlers import BaseHandler
from crutches_on_wheels.web.request import VLRequest


[docs]class CommonBaseHandler(BaseHandler): """ Base handler for all the handlers in this project. Attributes: facesDBContext (DBContext): Faces database context eventsDBContext (EventsDBContext): Events database context attributesDBContext (AttributesDBContext): Attributes database context """ def __init__(self, request: VLRequest): """ Init base handler Args: request: input request class """ super().__init__(request) self.facesDBContext = request.app.ctx.facesDBContext self.eventsDBContext = request.app.ctx.eventsDBContext self.attributesDBContext = request.app.ctx.attributesDBContext @property def app(self) -> Union[PythonMatcherApp, PythonMatcherProxyApp]: """ Get running app Returns: app """ return self.request.app @property def config(self) -> Union[SettingsPythonMatcher, SettingsPythonMatcherProxy]: """ Get app config Returns: app config """ return self.app.ctx.serviceConfig