=== modified file 'django/template/defaulttags.py'
|
|
|
6 | 6 | from django.conf import settings |
7 | 7 | import sys |
8 | 8 | |
| 9 | if not hasattr(__builtins__, 'reversed'): |
| 10 | # From http://www.python.org/doc/current/tut/node11.html |
| 11 | def reversed(data): |
| 12 | for index in xrange(len(data)-1, -1, -1): |
| 13 | yield data[index] |
| 14 | |
| 15 | |
9 | 16 | register = Library() |
10 | 17 | |
11 | 18 | class CommentNode(Node): |
… |
… |
|
102 | 109 | values = list(values) |
103 | 110 | len_values = len(values) |
104 | 111 | if self.reversed: |
105 | | # From http://www.python.org/doc/current/tut/node11.html |
106 | | def reverse(data): |
107 | | for index in range(len(data)-1, -1, -1): |
108 | | yield data[index] |
109 | | values = reverse(values) |
| 112 | values = reversed(values) |
110 | 113 | for i, item in enumerate(values): |
111 | 114 | context['forloop'] = { |
112 | 115 | # shortcuts for current loop iteration number |