#18979: PermWrapper + template "if in" interaction
---------------------------------+--------------------------------------
Reporter: akaariai | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Comment (by akaariai):
I am completely lost with this ticket... I replaced the contents of the
some_view (testing/views.py) with this:
{{{
def some_view(request):
context_instance=RequestContext(request)
testing_perms = context_instance['perms']['testing']
'foo' in testing_perms
ret = render_to_response('a_template.html', {'foo': 'bar'},
context_instance=RequestContext(request))
return ret
}}}
Then, I placed a {{{ print(__getitem__(%s) % perm_name) }}} into {{{
django/contrib/auth/context_processors.py:PermLookupDict.__getitem__. }}}.
Access the view and it prints this endlessly:
{{{
__getitem__(0)
__getitem__(1)
__getitem__(2)
...
}}}
The stack trace is this:
{{{
^Cakaariai@akaariai-UX31E:~/Programming/tester$ python manage.py runserver
Validating models...
0 errors found
September 18, 2012 - 13:46:04
Django version 1.5.dev20120917231511, using settings 'tester.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
__getitem__(0)
>
/home/akaariai/Programming/tester/django/contrib/auth/context_processors.py(14)__getitem__()
-> return self.user.has_perm("%s.%s" % (self.module_name, perm_name))
(Pdb) perm_name
0
(Pdb) bt
/usr/local/lib/python2.7/threading.py(524)__bootstrap()
-> self.__bootstrap_inner()
/usr/local/lib/python2.7/threading.py(551)__bootstrap_inner()
-> self.run()
/usr/local/lib/python2.7/threading.py(504)run()
-> self.__target(*self.__args, **self.__kwargs)
/usr/local/lib/python2.7/SocketServer.py(582)process_request_thread()
-> self.finish_request(request, client_address)
/usr/local/lib/python2.7/SocketServer.py(323)finish_request()
-> self.RequestHandlerClass(request, client_address, self)
/home/akaariai/Programming/tester/django/core/servers/basehttp.py(140)__init__()
-> super(WSGIRequestHandler, self).__init__(*args, **kwargs)
/usr/local/lib/python2.7/SocketServer.py(638)__init__()
-> self.handle()
/usr/local/lib/python2.7/wsgiref/simple_server.py(124)handle()
-> handler.run(self.server.get_app())
/usr/local/lib/python2.7/wsgiref/handlers.py(85)run()
-> self.result = application(self.environ, self.start_response)
/home/akaariai/Programming/tester/django/contrib/staticfiles/handlers.py(71)__call__()
-> return self.application(environ, start_response)
/home/akaariai/Programming/tester/django/core/handlers/wsgi.py(236)__call__()
-> response = self.get_response(request)
/home/akaariai/Programming/tester/django/core/handlers/base.py(115)get_response()
-> response = callback(request, *callback_args, **callback_kwargs)
/home/akaariai/Programming/tester/testing/views.py(7)some_view()
-> 'foo' in testing_perms
>
/home/akaariai/Programming/tester/django/contrib/auth/context_processors.py(14)__getitem__()
-> return self.user.has_perm("%s.%s" % (self.module_name, perm_name))
}}}
Tested both on Python 3.2 and Python 2.7, and at least 1.4.0 has this
already.
--
Ticket URL: <https://code.djangoproject.com/ticket/18979#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.