core.utils ========== .. py:module:: core.utils Submodules ---------- .. toctree:: :maxdepth: 1 /viur/core/utils/json/index /viur/core/utils/parse/index /viur/core/utils/string/index Attributes ---------- .. autoapisummary:: core.utils.__UTILS_CONF_REPLACEMENT core.utils.__UTILS_NAME_REPLACEMENT Functions --------- .. autoapisummary:: core.utils.utcNow core.utils.seoUrlToEntry core.utils.seoUrlToFunction core.utils.normalizeKey core.utils.get_base_url core.utils.ensure_iterable core.utils.build_content_disposition_header core.utils.__getattr__ Package Contents ---------------- .. py:function:: utcNow() Returns an actual timestamp with UTC timezone setting. .. py:function:: seoUrlToEntry(module, entry = None, skelType = None, language = None) Return the seo-url to a skeleton instance or the module. :param module: The module name. :param entry: A skeleton instance or None, to get the path to the module. :param skelType: # FIXME: Not used :param language: For which language. If None, the language of the current request is used. :return: The path (with a leading /). .. py:function:: seoUrlToFunction(module, function, render = None) .. py:function:: normalizeKey(key) Normalizes a datastore key (replacing _application with the current one) :param key: Key to be normalized. :return: Normalized key in string representation. .. py:function:: get_base_url() Retrieve current request's base URL with protocol. The function enforces use of https-protocol on non-localhost hostnames. :returns: Returns the hostname, including the currently used protocol, e.g: https://www.example.com :rtype: str .. py:function:: ensure_iterable(obj, *, test = None, allow_callable = True) Ensures an object to be iterable. An additional test can be provided to check additionally. If the object is not considered to be iterable, a tuple with the object is returned. .. py:function:: build_content_disposition_header(filename, *, attachment = False, inline = False) Build a Content-Disposition header with UTF-8 support and ASCII fallback. Generates a properly formatted `Content-Disposition` header value, including both a fallback ASCII filename and a UTF-8 encoded filename using RFC 5987. Set either `attachment` or `inline` to control content disposition type. If both are False, the header will omit disposition type (not recommended). Example: filename = "Änderung.pdf" ➜ 'attachment; filename="Anderung.pdf"; filename*=UTF-8''%C3%84nderung.pdf' :param filename: The desired filename for the content. :param attachment: Whether to mark the content as an attachment. :param inline: Whether to mark the content as inline. :return: A `Content-Disposition` header string. .. py:data:: __UTILS_CONF_REPLACEMENT .. py:data:: __UTILS_NAME_REPLACEMENT .. py:function:: __getattr__(attr)