core.utils¶
Submodules¶
Attributes¶
Functions¶
|
Returns an actual timestamp with UTC timezone setting. |
|
Return the seo-url to a skeleton instance or the module. |
|
|
|
Normalizes a datastore key (replacing _application with the current one) |
|
Ensures an object to be iterable. |
|
Build a Content-Disposition header with UTF-8 support and ASCII fallback. |
|
Package Contents¶
- core.utils.utcNow()¶
Returns an actual timestamp with UTC timezone setting.
- Return type:
datetime.datetime
- core.utils.seoUrlToEntry(module, entry=None, skelType=None, language=None)¶
Return the seo-url to a skeleton instance or the module.
- Parameters:
module (str) – The module name.
entry (Optional[viur.core.skeleton.SkeletonInstance]) – A skeleton instance or None, to get the path to the module.
skelType (Optional[str]) – # FIXME: Not used
language (Optional[str]) – For which language. If None, the language of the current request is used.
- Returns:
The path (with a leading /).
- Return type:
str
- core.utils.seoUrlToFunction(module, function, render=None)¶
- Parameters:
module (str)
function (str)
render (Optional[str])
- Return type:
str
- core.utils.normalizeKey(key)¶
Normalizes a datastore key (replacing _application with the current one)
- Parameters:
key (Union[None, viur.core.db.Key]) – Key to be normalized.
- Returns:
Normalized key in string representation.
- Return type:
Union[None, viur.core.db.Key]
- core.utils.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.
- Parameters:
obj (Any)
test (Optional[Callable[[Any], bool]])
allow_callable (bool)
- Return type:
Iterable[Any]
- core.utils.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’
- Parameters:
filename (str) – The desired filename for the content.
attachment (bool) – Whether to mark the content as an attachment.
inline (bool) – Whether to mark the content as inline.
- Returns:
A Content-Disposition header string.
- Return type:
str
- core.utils.__UTILS_CONF_REPLACEMENT¶
- core.utils.__UTILS_NAME_REPLACEMENT¶
- core.utils.__getattr__(attr)¶