calculated ok

This commit is contained in:
gwen 2026-01-09 13:01:49 +01:00
parent 3823642352
commit ff9c0650fc
2 changed files with 25 additions and 17 deletions

View file

@ -1,6 +1,8 @@
Calculated default values
==============================
.. _calculated_variable:
Synopsis
-----------
@ -199,9 +201,9 @@ Inside a variable's `calculation` we can use relative path. "_" means that other
For example, in variable2's `calculation`, we can use relative path:
- __.variable1
- _.variable3
- __.family2.subfamily1.variable4
- `__.variable1`
- `_.variable3`
- `__.family2.subfamily1.variable4`
But we cannot access to extra1 variables with relative path.
@ -222,8 +224,8 @@ Hire is a dynamic family "{{ suffix }}":
For variable2's calculation, we can use:
- rougail.{{ suffix }}.variable3
- _.variable3
- `rougail.{{ suffix }}.variable3`
- `_.variable3`
In this case, we get value for "variable3" with the same suffix as "variable2".
@ -231,13 +233,13 @@ For variable4's calculation, we have two possibility:
- retrieves all values with all suffixes:
- rougail.{{ suffix }}.variable3
- __.{{ suffix }}.variable3
- `rougail.{{ suffix }}.variable3`
- `__.{{ suffix }}.variable3`
- retrieves a value for a specified suffix:
- rougail.val1.variable3
- __.val1.variable3
- `rougail.val1.variable3`
- `__.val1.variable3`
Examples
-----------

View file

@ -68,8 +68,8 @@ except that it is dedicated to the HTTPS protocol :ref:`and a boolean variable t
This `https_proxy` family is identical to the `http_proxy` family except that it defines variables intended for the HTTPS protocol.
Calculated default values
------------------------------
A default value calculated from another variable
--------------------------------------------------
.. type-along:: For those who follow the tutorial with the help of the git repository
@ -151,15 +151,19 @@ The target variable is `http_proxy.address`.
.. note:: The `__.` notation means the parent path of the current subfamily path.
We then say that the `manual.https_proxy.address` and the the `manual.https_proxy.port` default values are *calculated*.
We then say that the `manual.https_proxy.address` and the `manual.https_proxy.port` default values are *calculated*.
.. glossary::
calculated
We say that a variable's value or a default variable's value is calculated
when there is a pointer which refers to another variable's value
or if there is some :term:`jinja` code or a python function that calculates it.
We say that a variable's value or a default variable's value is calculated
when there is a pointer which refers to another variable's value.
:ref:`Other types of calculations exists <calculated_variable>`, in which this type of behavior does not occur
(the "pointer" behavior, notably type copying).
The other types of calculation we will be explained later in this tutorial.
Notice that the default value is not changed when :term:`user data <user data>` are settled.
@ -220,14 +224,16 @@ We have this result:
<span style="color: #5c5cff"> </span><span style="color: #5c5cff"> </span><span style="color: #5c5cff">┗━━ </span>📓 port (HTTPS Port): <span style="color: #ffd700">3128</span>
</pre>
We see that the default value is not changed.
The `https_proxy` variable's value is indeed modified, but the default value is still a calculated value (so the default value is indeed the value of the variable `http_proxy.address`, i.e., `"http.proxy.net"`), while the value defined by the user is `https.proxy.net`.
Here we see that the variable's default value is not changed, but rather its actual value.
.. keypoints:: Key points progress
**summary**
We have learned how to set the default value of the `https_proxy.address` variable
with the default value of the `http_proxy.address` variable. We did the same
with the value of the `http_proxy.address` variable. We did the same
`https_proxy.port` and the `https_proxy.port` variables.
**notation**