1from zope.interface import Interface
2from zope.interface import Attribute
3
4
5class ITALExpressionErrorInfo(Interface):
6
7    type = Attribute("type",
8                     "The exception class.")
9
10    value = Attribute("value",
11                      "The exception instance.")
12
13    lineno = Attribute("lineno",
14                       "The line number the error occurred on in the source.")
15
16    offset = Attribute("offset",
17                       "The character offset at which the error occurred.")
18
19
20class ITALIterator(Interface):  # pragma: no cover
21    """A TAL iterator
22
23    Not to be confused with a Python iterator.
24    """
25
26    def next():
27        """Advance to the next value in the iteration, if possible
28
29        Return a true value if it was possible to advance and return
30        a false value otherwise.
31        """
32
33
34class ITALESIterator(ITALIterator):  # pragma: no cover
35    """TAL Iterator provided by TALES
36
37    Values of this iterator are assigned to items in the repeat namespace.
38
39    For example, with a TAL statement like: tal:repeat="item items",
40    an iterator will be assigned to "repeat/item".  The iterator
41    provides a number of handy methods useful in writing TAL loops.
42
43    The results are undefined of calling any of the methods except
44    'length' before the first iteration.
45    """
46
47    def index():
48        """Return the position (starting with "0") within the iteration
49        """
50
51    def number():
52        """Return the position (starting with "1") within the iteration
53        """
54
55    def even():
56        """Return whether the current position is even
57        """
58
59    def odd():
60        """Return whether the current position is odd
61        """
62
63    def parity():
64        """Return 'odd' or 'even' depending on the position's parity
65
66        Useful for assigning CSS class names to table rows.
67        """
68
69    def start():
70        """Return whether the current position is the first position
71        """
72
73    def end():
74        """Return whether the current position is the last position
75        """
76
77    def letter():
78        """Return the position (starting with "a") within the iteration
79        """
80
81    def Letter():
82        """Return the position (starting with "A") within the iteration
83        """
84
85    def roman():
86        """Return the position (starting with "i") within the iteration
87        """
88
89    def Roman():
90        """Return the position (starting with "I") within the iteration
91        """
92
93    def item():
94        """Return the item at the current position
95        """
96
97    def length():
98        """Return the length of the sequence
99
100        Note that this may fail if the TAL iterator was created on a Python
101        iterator.
102        """
103