Ticket #15840: 15840.patch.3.diff

File 15840.patch.3.diff, 1.5 KB (added by Zbigniew Siciarz, 12 years ago)

Improved the patch so it applies cleanly to current trunk. Only the condition decorator needs testing, as the other two are implemented in terms of it.

  • django/views/decorators/http.py

    diff --git a/django/views/decorators/http.py b/django/views/decorators/http.py
    index 495a7b1..c282da5 100644
    a b def condition(etag_func=None, last_modified_func=None):  
    153153
    154154            return response
    155155
    156         return inner
     156        return wraps(func, assigned=available_attrs(func))(inner)
    157157    return decorator
    158158
    159159# Shortcut decorators for common cases based on ETag or Last-Modified only
  • tests/regressiontests/decorators/tests.py

    diff --git a/tests/regressiontests/decorators/tests.py b/tests/regressiontests/decorators/tests.py
    index 51f75d7..749df43 100644
    a b from django.utils.functional import allow_lazy, lazy, memoize  
    1111from django.utils.unittest import TestCase
    1212from django.views.decorators.cache import cache_page, never_cache, cache_control
    1313from django.views.decorators.clickjacking import xframe_options_deny, xframe_options_sameorigin, xframe_options_exempt
    14 from django.views.decorators.http import require_http_methods, require_GET, require_POST, require_safe
     14from django.views.decorators.http import require_http_methods, require_GET, require_POST, require_safe, condition
    1515from django.views.decorators.vary import vary_on_headers, vary_on_cookie
    1616
    1717
    full_decorator = compose(  
    3838    require_GET,
    3939    require_POST,
    4040    require_safe,
     41    condition(lambda r: None, lambda r: None),
    4142
    4243    # django.views.decorators.vary
    4344    vary_on_headers('Accept-language'),
Back to Top