Esempio n. 1
0
    def __init__(
        self,
        req: http.Request,
        resp: http.Response,
        funnel: OutputFunnel,
        config_obj: Config,
        html_obj: Optional[htmllib.html] = None,
        timeout_manager: Optional[TimeoutManager] = None,  # pylint: disable=redefined-outer-name
        theme: Optional[Theme] = None,  # pylint: disable=redefined-outer-name
        display_options: Optional[DisplayOptions] = None,  # pylint: disable=redefined-outer-name
        prefix_logs_with_url: bool = True,
    ):
        self.html = html_obj
        self.auth_type: Optional[str] = None
        self.timeout_manager = timeout_manager
        self.theme = theme
        self.display_options = display_options
        self.session: Optional[userdb.Session] = None
        self.flashes: Optional[List[str]] = None
        self._prefix_logs_with_url = prefix_logs_with_url

        self.request = req
        self.response = resp
        self.output_funnel = funnel
        self.config = config_obj

        # TODO: cyclical import with config -> globals -> config -> ...
        from cmk.gui.utils.logged_in import LoggedInNobody
        self._user: LoggedInUser = LoggedInNobody()
        # TODO: This needs to be a helper of LoggedInUser
        self.transactions = TransactionManager(req, self._user)
        self.user_errors = UserErrors()

        self._prepend_url_filter = _PrependURLFilter()
        self._web_log_handler: Optional[logging.Handler] = None
Esempio n. 2
0
def makeactionuri_contextless(
    request: Request,
    transaction_manager: TransactionManager,
    addvars: HTTPVariables,
    filename: Optional[str] = None,
) -> str:
    return makeuri_contextless(
        request,
        addvars + [("_transid", transaction_manager.get())],
        filename=filename,
    )
Esempio n. 3
0
def makeactionuri(
    request: Request,
    transaction_manager: TransactionManager,
    addvars: HTTPVariables,
    filename: Optional[str] = None,
    delvars: Optional[Sequence[str]] = None,
) -> str:
    return makeuri(
        request,
        addvars + [("_transid", transaction_manager.get())],
        filename=filename,
        delvars=delvars,
    )
Esempio n. 4
0
    def __init__(self, user_id: Optional[str]) -> None:
        self.id = UserId(user_id) if user_id else None
        self.transactions = TransactionManager(request, self)

        self.confdir = _confdir_for_user_id(self.id)
        self.role_ids = self._gather_roles(self.id)
        baserole_ids = _baserole_ids_from_role_ids(self.role_ids)
        self.baserole_id = _most_permissive_baserole_id(baserole_ids)
        self._attributes = self._load_attributes(self.id, self.role_ids)
        self.alias = self._attributes.get("alias", self.id)
        self.email = self._attributes.get("email", self.id)

        self._permissions = _initial_permission_cache(self.id)
        self._siteconf = self.load_file("siteconfig", {})
        self._button_counts: Dict[str, float] = {}
        self._stars: Set[str] = set()
        self._tree_states: Dict = {}
        self._bi_assumptions: Dict[Union[Tuple[str, str], Tuple[str, str, str]], int] = {}
        self._tableoptions: Dict[str, Dict[str, Any]] = {}
Esempio n. 5
0
def tm():
    request = http.Request({"wsgi.input": "", "SCRIPT_NAME": ""})
    return TransactionManager(request)
Esempio n. 6
0
 def user(self, user_obj: LoggedInUser) -> None:
     self._user = user_obj
     self.transactions = TransactionManager(request, user_obj)