def load_from_html(self, request: Request, html: htmllib.html) -> None: # Parse display options and if html.output_format == "html": options = request.get_ascii_input_mandatory("display_options", "") else: options = self.all_off() # Remember the display options in the object for later linking etc. self.options = self._merge_with_defaults(options) # This is needed for letting only the data table reload. The problem is that # the data table is re-fetched via javascript call using special display_options # but these special display_options must not be used in links etc. So we use # a special var _display_options for defining the display_options for rendering # the data table to be reloaded. The contents of "display_options" are used for # linking to other views. if request.has_var('_display_options'): self.options = self._merge_with_defaults( request.get_ascii_input_mandatory("_display_options", "")) # But there is one special case: Links to other views (sorter header links, painter column # links). These links need to know about the provided display_option parameter. The links # could use "display_options.options" but this contains the implicit options which should # not be added to the URLs. So the real parameters need to be preserved for this case. self.title_options = request.get_ascii_input("display_options") # If display option 'M' is set, then all links are targetet to the 'main' # frame. Also the display options are removed since the view in the main # frame should be displayed in standard mode. if self.disabled(self.M): html.set_link_target("main") request.del_var("display_options")
def is_mobile(request: Request, response: Response) -> bool: if request.has_var("mobile"): mobile = bool(request.var("mobile")) # Persist the explicitly set state in a cookie to have it maintained through further requests response.set_http_cookie("mobile", str(int(mobile)), secure=request.is_secure) return mobile if request.has_cookie("mobile"): return request.cookie("mobile", "0") == "1" return _is_mobile_client(request.user_agent.string)