core.render.html.env.viur
¶
Module Contents¶
Functions¶
|
Jinja2 global: Perform an internal Request. |
|
Jinja2 global: Returns the current user from the session, or None if not logged in. |
|
Jinja2 global: Fetch an entry from a given module, and return the data as a dict, |
|
Jinja2 global: Retrieve hostname with protocol. |
|
Jinja2 global: Redirect to another URL. |
|
Jinja2 global: Returns the language used for this request. |
|
Jinja2 global: Retrieve name of current module where this renderer is used within. |
|
Jinja2 global: Retrieve path of current module the renderer is used within. |
|
Jinja2 global: Fetches a list of entries which match the given filter criteria. |
|
Jinja2 global: Creates a new ViUR security key. |
|
Jinja2 global: Returns the skeleton structure instead of data for a module. |
|
Jinja2 global: Allows for accessing the request-parameters from the template. |
|
Jinja2 global: Constructs a new URL based on the current requests url. |
|
Jinja2 filter: Format the value in an 'human-readable' file size (i.e. 13 kB, 4.1 MB, 102 Bytes, etc). |
|
Jinja2 filter: Make a string URL-safe. |
|
Jinja2 filter: Make a shortkey from an entity-key. |
|
|
|
|
|
jinja2 function to get an <img/>-tag for a SVG. |
|
Constructs a signed download-url for the given file-bone. Mostly a wrapper around |
|
|
|
|
|
- core.render.html.env.viur.execRequest(render, path, *args, **kwargs)¶
Jinja2 global: Perform an internal Request.
This function allows to embed the result of another request inside the current template. All optional parameters are passed to the requested resource.
- Parameters
path – Local part of the url, e.g. user/list. Must not start with an /.
Must not include an protocol or hostname. :type path: str
- Returns
Whatever the requested resource returns. This is not limited to strings!
- core.render.html.env.viur.getCurrentUser(render)¶
Jinja2 global: Returns the current user from the session, or None if not logged in.
- Returns
A dict containing user data. Returns None if no user data is available.
- Return type
dict
- core.render.html.env.viur.getSkel(render, module, key=None, skel='viewSkel')¶
Jinja2 global: Fetch an entry from a given module, and return the data as a dict, prepared for direct use in the output.
It is possible to specify a different data-model as the one used for rendering (e.g. an editSkel).
- Parameters
module (str) – Name of the module, from which the data should be fetched.
key – Requested entity-key in an urlsafe-format. If the module is a Singleton
application, the parameter can be omitted. :type key: str
- Parameters
skel (str) – Specifies and optionally different data-model
- Returns
dict on success, False on error.
- Return type
dict | bool
- core.render.html.env.viur.getHostUrl(render, forceSSL=False, *args, **kwargs)¶
Jinja2 global: Retrieve hostname with protocol.
- Returns
Returns the hostname, including the currently used protocol, e.g: http://www.example.com
- Return type
str
- core.render.html.env.viur.redirect(render, url)¶
Jinja2 global: Redirect to another URL.
- Parameters
url (str) – URL to redirect to.
- core.render.html.env.viur.getLanguage(render, resolveAlias=False)¶
Jinja2 global: Returns the language used for this request.
- Parameters
resolveAlias – If True, the function tries to resolve the current language
using conf[“viur.languageAliasMap”]. :type resolveAlias: bool
- core.render.html.env.viur.moduleName(render)¶
Jinja2 global: Retrieve name of current module where this renderer is used within.
- Returns
Returns the name of the current module, or empty string if there is no module set.
- core.render.html.env.viur.modulePath(render)¶
Jinja2 global: Retrieve path of current module the renderer is used within.
- Returns
Returns the path of the current module, or empty string if there is no module set.
- core.render.html.env.viur.getList(render: viur.core.render.html.default.Render, module: str, skel: str = 'viewSkel', _noEmptyFilter: bool = False, *args, **kwargs) Union[bool, None, List[viur.core.skeleton.SkeletonInstance]] ¶
Jinja2 global: Fetches a list of entries which match the given filter criteria.
- Parameters
module – Name of the module from which list should be fetched.
skel – Name of the skeleton that is used to fetching the list.
_noEmptyFilter – If True, this function will not return any results if at least one
parameter is an empty list. This is useful to prevent filtering (e.g. by key) not being performed because the list is empty. :returns: Returns a dict that contains the “skellist” and “cursor” information, or None on error case.
- core.render.html.env.viur.getSecurityKey(render, **kwargs)¶
Jinja2 global: Creates a new ViUR security key.
- core.render.html.env.viur.getStructure(render, module, skel='viewSkel', subSkel=None)¶
Jinja2 global: Returns the skeleton structure instead of data for a module.
- Parameters
module (str) – Module from which the skeleton is retrieved.
skel (str) – Name of the skeleton.
subSkel (str or None) – If set, return just that subskel instead of the whole skeleton
- core.render.html.env.viur.requestParams(render)¶
Jinja2 global: Allows for accessing the request-parameters from the template.
These returned values are escaped, as users tend to use these in an unsafe manner.
- Returns
dict of parameter and values.
- Return type
dict
- core.render.html.env.viur.updateURL(render, **kwargs)¶
Jinja2 global: Constructs a new URL based on the current requests url.
Given parameters are replaced if they exists in the current requests url, otherwise there appended.
- Returns
Returns a well-formed URL.
- Return type
str
- core.render.html.env.viur.fileSize(render, value, binary=False)¶
Jinja2 filter: Format the value in an ‘human-readable’ file size (i.e. 13 kB, 4.1 MB, 102 Bytes, etc). Per default, decimal prefixes are used (Mega, Giga, etc.). When the second parameter is set to True, the binary prefixes are used (Mebi, Gibi).
- Parameters
value (int | float) – Value to be calculated.
binary (bool) – Decimal prefixes behavior
- Returns
The formatted file size string in human readable format.
- Type
str
- core.render.html.env.viur.urlencode(render, val)¶
Jinja2 filter: Make a string URL-safe.
- Parameters
val (str) – String to be quoted.
- Returns
Quoted string.
- Return type
str
- core.render.html.env.viur.shortKey(render, val)¶
Jinja2 filter: Make a shortkey from an entity-key.
- Parameters
val (str) – Entity-key as string.
- Returns
Shortkey on success, None on error.
- Return type
str
- core.render.html.env.viur.renderEditBone(render, skel, boneName, boneErrors=None, prefix=None)¶
- core.render.html.env.viur.renderEditForm(render, skel, ignore=None, hide=None, prefix=None)¶
- core.render.html.env.viur.embedSvg(render, name: str, classes: Union[List[str], None] = None, **kwargs: Dict[str, str]) str ¶
jinja2 function to get an <img/>-tag for a SVG. This method will not check the existence of a SVG!
- Parameters
render – The jinja renderer instance
name – Name of the icon (basename of file)
classes – A list of css-classes for the <img/>-tag
kwargs – Further html-attributes for this tag (e.g. “alt” or “title”)
- Returns
A <img/>-tag
- core.render.html.env.viur.downloadUrlFor(render: viur.core.render.html.default.Render, fileObj: dict, expires: Union[None, int] = conf['viur.downloadUrlFor.expiration'], derived: Optional[str] = None) Optional[str] ¶
Constructs a signed download-url for the given file-bone. Mostly a wrapper around
viur.core.utils.downloadUrlFor()
.- Parameters
fileObj – The file-bone (eg. skel[“file”])
expires – None if the file is supposed to be public (which causes it to be cached on the google ede caches), otherwise it’s lifetime in seconds
derived – Optional the filename of a derived file, otherwise the the download-link will point to the originally uploaded file.
- Returns
THe signed download-url relative to the current domain (eg /download/…)
- core.render.html.env.viur.srcSetFor(render, fileObj, expires)¶
- core.render.html.env.viur.seoUrlForEntry(render, *args, **kwargs)¶
- core.render.html.env.viur.seoUrlToFunction(render, *args, **kwargs)¶