[...]
File
"/usr/lib/python2.4/site-packages/django/core/context_processors.py",
line 17, in auth
return {
AttributeError: 'ModPythonRequest' object has no attribute 'user'
Is Django's authentication system needed in order to raise 404s? I had
a look to context_processors.py and got convinced that the 'user'
attribute mentioned has something to do with the auth system.
The website I'm developing doesn't use a database actually, so I'm not
using the ORM and the features that depend on it (the auth system is
one of them, right?).
thanks in advance,
Filipe
Can you paste the full traceback for this, please? A few people have
reported this on and off; time to track down what's going on.
Thanks,
Malcolm
The full traceback follows:
________________________________________________________________
Mod_python error: "PythonHandler django.core.handlers.modpython"
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
result = object(req)
File
"/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py",
line 183, in handler
return ModPythonHandler()(req)
File
"/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py",
line 153, in __call__
response = self.get_response(req.uri, request)
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py",
line 95, in get_response
return callback(request, **param_dict)
File "/usr/lib/python2.4/site-packages/django/views/defaults.py",
line 79, in page_not_found
return http.HttpResponseNotFound(t.render(RequestContext(request,
{'request_path': request.path})))
File "/usr/lib/python2.4/site-packages/django/template/context.py",
line 97, in __init__
self.update(processor(request))
File
"/usr/lib/python2.4/site-packages/django/core/context_processors.py",
line 17, in auth
return {
AttributeError: 'ModPythonRequest' object has no attribute 'user'
________________________________________________________________
thanks!
Filipe
OK, this is the problem line: RequestContext tries to access "user". The
reason we are using RequestContext is because of ticket #688 (which is
quite a reasonable change). However, we have to conditionally avoid this
user requirement.
>
> File "/usr/lib/python2.4/site-packages/django/template/context.py",
> line 97, in __init__
> self.update(processor(request))
>
> File
> "/usr/lib/python2.4/site-packages/django/core/context_processors.py",
> line 17, in auth
> return {
>
> AttributeError: 'ModPythonRequest' object has no attribute 'user'
I'm a bit tired right now, so I'm stopping for the evening, but I'll
have a look at this tomorrow.
Regards,
Malcolm
> OK, this is the problem line: RequestContext tries to access "user". The
> reason we are using RequestContext is because of ticket #688 (which is
> quite a reasonable change). However, we have to conditionally avoid this
> user requirement.
Well, as a work around, if you don't use a database, you should
remove
"django.core.context_processors.auth",
from TEMPLATE_CONTEXT_PROCESSORS in settings.py
This setting makes some of the default views trigger a context
processor that requires the session middleware. Since this
middleware needs a database, you've probably switched it off.
Michael
hmm, I don't have that in settings.py. However, I do have:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'myproject.main',
)
I tried removing the reference to 'django.contrib.auth' and the error
remained, though.
Ah, it's there by default even if you don't have any settings for
it. See the code for django.conf.global_settings.
You need to copy the specific settings from
django.conf.global_settings to your settings module, it is:
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
# 'django.core.context_processors.request',
)
Then comment out context_processors.auth (or however you want to
deal with it), and get:
TEMPLATE_CONTEXT_PROCESSORS = (
# 'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
# 'django.core.context_processors.request',
)
I'm not sure if you run into other problems then, but let's deal
with those afterwards.
Michael
works perfectly. Haven't detected any side effect yet.
thanks.
> works perfectly. Haven't detected any side effect yet.
> thanks.
Good to know! Perhaps you should file a ticket that
context_processors.auth should behave better when there's no
session. If you do, please include a link to this thread.
Michael