Ticket #3828: 4828-fix-request-access.2.diff

File 4828-fix-request-access.2.diff, 754 bytes (added by David Danier <goliath.mailinglist@…>, 18 years ago)

getitem does not work for methods, as the resolver tries not to call values got by dict-access. Fixed this by using getattr instead.

  • django/core/context_processors.py

     
    4242
    4343    return context_extras
    4444
     45class TemplateRequestWrapper(object):
     46    def __init__(self, request):
     47        self._request = request
     48    def __repr__(self):
     49        return self._request.__repr__()
     50    def __getattr__(self, name):
     51        return getattr(self._request, name)
     52
    4553def request(request):
    46     return {'request': request}
     54    return {'request': TemplateRequestWrapper(request)}
    4755
    4856# PermWrapper and PermLookupDict proxy the permissions system into objects that
    4957# the template system can understand.
Back to Top