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

File 4828-fix-request-access.diff, 851 bytes (added by David Danier <goliath.mailinglist@…>, 18 years ago)
  • 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 __getitem__(self, name):
     51        # __getitem__ is used for optimization
     52        # (thats what the resolver tries first)
     53        return getattr(self._request, name)
     54
    4555def request(request):
    46     return {'request': request}
     56    return {'request': TemplateRequestWrapper(request)}
    4757
    4858# PermWrapper and PermLookupDict proxy the permissions system into objects that
    4959# the template system can understand.
Back to Top