OVH Cloud OVH Cloud

Problème de newby...METAL PYTHON variable

1 réponse
Avatar
Hymn
Bonjour

Après une journée de galère à essayer d'incrémenter un variable toute be
te, je me décide à poster mon problème dans ce forum...

Bon, j'aimerais simplement incrémenter une variable dans un <tal:block>.
.

J'arrive à déclarer la bête :
<tal:block define="monCpt python:1">

et dans un block "repeat", j'aimerais incrémenter ma variable "monCpt"..

1 réponse

Avatar
Bruno Desthuilliers
Hymn wrote:
Bonjour

Après une journée de galère à essayer d'incrémenter un variable toute be
te, je me décide à poster mon problème dans ce forum...

Bon, j'aimerais simplement incrémenter une variable dans un <tal:block>.
..

J'arrive à déclarer la bête :
<tal:block define="monCpt python:1">

et dans un block "repeat", j'aimerais incrémenter ma variable "monCpt"..



Pourquoi faire ?

"""
The following information is available from the repeat variable:

* index - repetition number, starting from zero.
* number - repetition number, starting from one.
* even - true for even-indexed repetitions (0, 2, 4, ...).
* odd - true for odd-indexed repetitions (1, 3, 5, ...).
* start - true for the starting repetition (index 0).
* end - true for the ending, or final, repetition.
* first - true for the first item in a group - see note below
* last - true for the last item in a group - see note below
* length - length of the sequence, which will be the total number
of repetitions.
* letter - repetition number as a lower-case letter: "a" - "z",
"aa" - "az", "ba" - "bz", ..., "za" - "zz", "aaa" - "aaz", and so forth.
* Letter - upper-case version of letter.
* roman - repetition number as a lower-case roman numeral: "i",
"ii", "iii", "iv", "v", etc.
* Roman - upper-case version of roman.

You can access the contents of the repeat variable using path
expressions or Python expressions. In path expressions, you write a
three-part path consisting of the name repeat, the statement variable's
name, and the name of the information you want, for example,
repeat/item/start. In Python expressions, you use normal dictionary
notation to get the repeat variable, then attribute access to get the
information, for example, "python:repeat['item'].start".
"""

Tu a donc à ta disposition les variables repeat['item'].index et
repeat['item'].number...

HTH
Bruno