Ticket #1840: admin-doc-views.diff

File admin-doc-views.diff, 2.7 KB (added by dummy@…, 18 years ago)

this maybe a solution

  • django/contrib/admin/views/decorators.py

     
    104104                        return http.HttpResponseRedirect(request.path)
    105105            else:
    106106                return _display_login_form(request, ERROR_MESSAGE)
     107    _checklogin._decorated_func = view_func
    107108
    108109    return _checklogin
  • django/contrib/admin/views/doc.py

     
    320320def get_readable_field_data_type(field):
    321321    return DATA_TYPE_MAPPING[field.get_internal_type()] % field.__dict__
    322322
     323def undecorate(func, i=0):
     324    try:
     325        if i > 10:
     326            print "Warning: endless looping !"
     327            return func
     328
     329        if func != func._decorated_func:
     330            func = undecorate(func._decorated_func,i+1)
     331    except:
     332        pass
     333
     334    return func
     335
    323336def extract_views_from_urlpatterns(urlpatterns, base=''):
    324337    """
    325338    Return a list of views from a list of urlpatterns.
     
    328341    """
    329342    views = []
    330343    for p in urlpatterns:
    331         if hasattr(p, 'get_callback'):
     344        if hasattr(p, '_get_callback'):
    332345            try:
    333                 views.append((p.get_callback(), base + p.regex.pattern))
     346                views.append((undecorate(p._get_callback()), base + p.regex.pattern))
    334347            except ViewDoesNotExist:
    335348                continue
    336349        elif hasattr(p, '_get_url_patterns'):
  • django/contrib/auth/decorators.py

     
    1515            return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, quote(request.get_full_path())))
    1616        _checklogin.__doc__ = view_func.__doc__
    1717        _checklogin.__dict__ = view_func.__dict__
     18        _checklogin._decorated_func = view_func
    1819
    1920        return _checklogin
     21
    2022    return _dec
    2123
    2224login_required = user_passes_test(lambda u: u.is_authenticated())
  • django/views/decorators/cache.py

     
    3939        response = view_func(request, *args, **kwargs)
    4040        add_never_cache_headers(response)
    4141        return response
     42    _wrapped_view_func._decorated_func = view_func
     43
    4244    return _wrapped_view_func
Back to Top