Django

Code

Changeset 7752

Show
Ignore:
Timestamp:
06/25/08 23:30:06 (5 months ago)
Author:
adrian
Message:

Fixed #6322 -- Fixed bug in 'ifchanged' template tag where it wasn't resetting itself properly in some cases. Thanks, nedbatchelder

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/template/defaulttags.py

    r7557 r7752  
    163163        self._last_seen = None 
    164164        self._varlist = map(Variable, varlist) 
    165  
    166     def render(self, context): 
    167         if 'forloop' in context and context['forloop']['first']: 
     165        self._id = str(id(self)) 
     166 
     167    def render(self, context): 
     168        if 'forloop' in context and self._id not in context['forloop']: 
    168169            self._last_seen = None 
     170            context['forloop'][self._id] = 1 
    169171        try: 
    170172            if self._varlist: 
  • django/trunk/tests/regressiontests/templates/tests.py

    r7751 r7752  
    136136        # Quickly check that we aren't accidentally using a name in both 
    137137        # template and filter tests. 
    138         overlapping_names = [name for name in filter_tests if name in 
    139                 template_tests] 
     138        overlapping_names = [name for name in filter_tests if name in template_tests] 
    140139        assert not overlapping_names, 'Duplicate test name(s): %s' % ', '.join(overlapping_names) 
    141140 
     
    160159        old_td, settings.TEMPLATE_DEBUG = settings.TEMPLATE_DEBUG, False 
    161160 
    162         # Set TEMPLATE_STRING_IF_INVALID to a known string 
     161        # Set TEMPLATE_STRING_IF_INVALID to a known string. 
    163162        old_invalid = settings.TEMPLATE_STRING_IF_INVALID 
    164163        expected_invalid_str = 'INVALID' 
     
    550549            'ifchanged06': ('{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% for x in numx %}{% ifchanged %}{{ x }}{% endifchanged %}{% endfor %}{% endfor %}', {'num': (1, 1, 1), 'numx': (2, 2, 2)}, '1222'), 
    551550            'ifchanged07': ('{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% for x in numx %}{% ifchanged %}{{ x }}{% endifchanged %}{% for y in numy %}{% ifchanged %}{{ y }}{% endifchanged %}{% endfor %}{% endfor %}{% endfor %}', {'num': (1, 1, 1), 'numx': (2, 2, 2), 'numy': (3, 3, 3)}, '1233323332333'), 
     551            'ifchanged08': ('{% for data in datalist %}{% for c,d in data %}{% if c %}{% ifchanged %}{{ d }}{% endifchanged %}{% endif %}{% endfor %}{% endfor %}', {'datalist': [[(1, 'a'), (1, 'a'), (0, 'b'), (1, 'c')], [(0, 'a'), (1, 'c'), (1, 'd'), (1, 'd'), (0, 'e')]]}, 'accd'), 
    552552 
    553553            # Test one parameter given to ifchanged.