core.bones.uri¶
Attributes¶
Classes¶
The BaseBone class serves as the base class for all bone types in the ViUR framework. |
Module Contents¶
- core.bones.uri.PORT_MIN: Final[int] = 1¶
- core.bones.uri.PORT_MAX: Final[int] = 65535¶
- class core.bones.uri.UriBone(*, accepted_protocols=None, accepted_ports=None, clean_get_params=False, domain_allowed_list=None, domain_disallowed_list=None, local_path_allowed=False, **kwargs)¶
Bases:
core.bones.base.BaseBoneThe BaseBone class serves as the base class for all bone types in the ViUR framework. It defines the core functionality and properties that all bones should implement.
- Parameters:
descr – Textual, human-readable description of that bone. Will be translated.
defaultValue – If set, this bone will be preinitialized with this value
required – If True, the user must enter a valid value for this bone (the viur.core refuses to save the skeleton otherwise). If a list/tuple of languages (strings) is provided, these language must be entered.
multiple – If True, multiple values can be given. (ie. n:m relations instead of n:1)
searchable – If True, this bone will be included in the fulltext search. Can be used without the need of also been indexed.
type_suffix – Allows to specify an optional suffix for the bone-type, for bone customization
vfunc – If given, a callable validating the user-supplied value for this bone. This callable must return None if the value is valid, a String containing an meaningful error-message for the user otherwise.
readOnly – If True, the user is unable to change the value of this bone. If a value for this bone is given along the POST-Request during Add/Edit, this value will be ignored. Its still possible for the developer to modify this value by assigning skel.bone.value.
visible – If False, the value of this bone should be hidden from the user. This does not protect the value from being exposed in a template, nor from being transferred to the client (ie to the admin or as hidden-value in html-form)
compute –
If set, the bone’s value will be computed in the given method.
Note
The kwarg ‘multiple’ is not supported by all bones
accepted_protocols (str | Iterable[str] | None)
accepted_ports (int | str | Iterable[int] | Iterable[str] | None)
clean_get_params (bool)
domain_allowed_list (Iterable[str] | None)
domain_disallowed_list (Iterable[str] | None)
local_path_allowed (bool)
The UriBone is used for storing URI and URL.
- Parameters:
accepted_protocols (str | Iterable[str] | None) – The accepted protocols can be set to allow only the provide protocols.
accepted_ports (int | str | Iterable[int] | Iterable[str] | None)
clean_get_params (bool)
domain_allowed_list (Iterable[str] | None)
domain_disallowed_list (Iterable[str] | None)
local_path_allowed (bool)
:param accepted_ports The accepted ports can be set to allow only the provide ports. .. code-block:: python
# Example UriBone(accepted_ports=1) UriBone(accepted_ports=”2”) UriBone(accepted_ports=”1-4”) UriBone(accepted_ports=(1,”2”,”4-10”))
- Parameters:
clean_get_params (bool) – When set to True, the GET-parameter for the URL will be cleaned.
domain_allowed_list (Iterable[str] | None) – If set, only the URLs that are matched with an entry of this iterable will be accepted.
domain_disallowed_list (Iterable[str] | None) – If set, only the URLs that are not matched with an entry of this iterable will be accepted.
local_path_allowed (bool) – If True, the URLs that are local paths will be prefixed with “/”.
accepted_protocols (str | Iterable[str] | None)
accepted_ports (int | str | Iterable[int] | Iterable[str] | None)
- type = 'uri'¶
- accepted_protocols = None¶
- clean_get_params = False¶
- domain_allowed_list = None¶
- domain_disallowed_list = None¶
- local_path_allowed = False¶
- classmethod _build_accepted_ports(accepted_ports)¶
- Parameters:
accepted_ports (str | int | Iterable[str | int])
- Return type:
list[range]
- isInvalid(value)¶
Checks if the current value of the bone in the given skeleton is invalid. Returns None if the value would be valid for this bone, an error-message otherwise.
- Return type:
str | None
- singleValueFromClient(value, skel, bone_name, client_data)¶
Load a single value from a client
- Parameters:
value – The single value which should be loaded.
skel – The SkeletonInstance where the value should be loaded into.
bone_name – The bone name of this bone in the SkeletonInstance.
client_data – The data taken from the client, a dictionary with usually bone names as key
- Returns:
A tuple. If the value is valid, the first element is the parsed value and the second is None. If the value is invalid or not parseable, the first element is a empty value and the second a list of ReadFromClientError.
- Return type:
tuple
- structure()¶
Describes the bone and its settings as an JSON-serializable dict. This function has to be implemented for subsequent, specialized bone types.
- Return type:
dict