core.bones.spam
¶
Module Contents¶
Classes¶
A bone for storing numeric values, either integers or floats. |
- class core.bones.spam.SpamBone(descr = i18n.translate('core.bones.spam.question', 'What is the result of the addition of {{a}} and {{b}}?'), values = tuple((i18n.translate(f'core.bones.spam.value.{digit}', digit) for digit in ('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'))), required = True, msg_invalid = i18n.translate('core.bones.spam.invalid', 'Your answer was wrong! Please try again.'), **kwargs)¶
Bases:
viur.core.bones.NumericBone
A bone for storing numeric values, either integers or floats. For floats, the precision can be specified in decimal-places.
Initializes a new NumericBone.
- Parameters:
min – Minimum accepted value (including).
max – Maximum accepted value (including).
precision – How may decimal places should be saved. Zero casts the value to int instead of float.
descr (str) –
values (Iterable[str]) –
required (bool) –
msg_invalid (str) –
- property descr¶
The descr-property is generated and uses session variables to construct the question.
- type = 'numeric.spam'¶
- _dice()¶
- Return type:
int
- isInvalid(value)¶
This method checks if a given value is invalid (e.g., NaN) for the NumericBone instance.
- Parameters:
value – The value to be checked for validity.
- Returns:
Returns a string “NaN not allowed” if the value is invalid (NaN), otherwise None.