First time here? Check out the FAQ!
0

UndefinedError: 'settings' is undefined

  • retag add tags

Hi, I'm on the current pip version on debian squeeze. The main part of the page is working, but if I e.g. want to change the "Site" via the admin interface the following error occurs:

My installation tries to render {{ settings.APP_TITLE|escape }} in /usr/local/lib/python2.6/dist-packages/askbot/templates/base.html" and throws "UndefinedError: 'settings' is undefined". Can anyone help me?

I have included this line

'askbot.context.application_settings',

in my settings in the TEMPLATE_CONTEXT_PROCESSORS which should make {{ settings}} available...

Here is the full traceback:

[Sat Dec 08 22:48:29 2012] [error][client x:x:x:x:x:x:x:x] mod_wsgi(pid=29866): Exception occurred processing WSGI script '/path/to/askbotproject/django.wsgi'.
[Sat Dec 08 22:48:29 2012] [error] [client x:x:x:x:x:x:x:x] Traceback (most recent call last): 
[Sat Dec 08 22:48:29 2012] [error] [client x:x:x:x:x:x:x:x]   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line 241, in __call__ 
[Sat Dec 08 22:48:29 2012] [error] [client x:x:x:x:x:x:x:x]     response = self.get_response(request)
[Sat Dec 08 22:48:29 2012] [error] [client x:x:x:x:x:x:x:x]   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 179, in get_response
[Sat Dec 08 22:48:29 2012] [error] [client x:x:x:x:x:x:x:x]     response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Sat Dec 08 22:48:29 2012] [error] [client x:x:x:x:x:x:x:x]   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 228, in handle_uncaught_exception
[Sat Dec 08 22:48:29 2012] [error] [client x:x:x:x:x:x:x:x]     return callback(request, **param_dict)
[Sat Dec 08 22:48:29 2012] [error] [client x:x:x:x:x:x:x:x]   File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py", line 91, in _wrapped_view
[Sat Dec 08 22:48:29 2012] [error] [client x:x:x:x:x:x:x:x]     response = view_func(request, *args, **kwargs)
[Sat Dec 08 22:48:29 2012] [error] [client x:x:x:x:x:x:x:x]   File "/usr/local/lib/python2.6/dist-packages/django/views/defaults.py", line 33, in server_error
[Sat Dec 08 22:48:29 2012] [error] [client x:x:x:x:x:x:x:x]     return http.HttpResponseServerError(t.render(Context({})))
[Sat Dec 08 22:48:29 2012] [error] [client x:x:x:x:x:x:x:x]   File "/usr/local/lib/python2.6/dist-packages/coffin/template/__init__.py", line 55, in render
[Sat Dec 08 22:48:29 2012] [error] [client x:x:x:x:x:x:x:x]     return super(Template, self).render(**context)
[Sat Dec 08 22:48:29 2012] [error] [client x:x:x:x:x:x:x:x]   File "/usr/local/lib/python2.6/dist-packages/jinja2/environment.py", line 894 ...
(more)
asmaps's avatar
21
asmaps
asked 2012-12-08 16:08:47 -0500, updated 2012-12-08 16:12:48 -0500
edit flag offensive 0 remove flag close merge delete

Comments

edit: Just noticed that the error also occurs when I try to show the help page.

asmaps's avatar asmaps (2012-12-08 16:31:44 -0500) edit

Could you specify steps to reproduce the issue, please? Also please tell which version of askbot this issue applies to.

Evgeny's avatar Evgeny (2012-12-09 10:31:23 -0500) edit

Hi, thanks for your reply. I'm using 0.7.44 (installed via pip).

asmaps's avatar asmaps (2012-12-09 11:11:23 -0500) edit

The error occurs when I try to open the help page or if I sumit changes of the "Site" via the admin interface. I think there are more places where this happens, but these two are where I recognized it.

asmaps's avatar asmaps (2012-12-09 11:12:34 -0500) edit

As I said I installed via "pip install askbot", then I ran manage.py syncdb and migrate. I added a user and wanted to change the site, but it didnt work. I also tried filling the database with dummydata but this (as expeted) also didnt change anything. If you like you can look to it on http://askbot.selfnet.de

asmaps's avatar asmaps (2012-12-09 11:15:15 -0500) edit
add a comment see more comments

2 Answers

0

Update: Now since I couldn't fix that problem I installed the version from git, but I get the same error. At least when I try to change the Site object. The help page is available now, that seems to be fixed by the update.

Is this really a bug or have I made a mistake?

asmaps's avatar
21
asmaps
answered 2012-12-09 17:26:06 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

"UndefinedError: 'settings' is undefined" exception in stactrace above happens in 500.html template. The'askbot.skins.loaders.Loader' is first loader in TEMPLATE_LOADERS. It loads 500.html(or 404, 403) template even outside of askbot app(for example in admin). Then it tries to render it, but there is no {{ settings }} in template context if current url not starts with ASKBOT_URL(see 'askbot.context.application_settings' context processor). The way to fix it is to use custom view to handle 500, 404, 403:

def view_500(request):
    if not request.path.startswith('/' + settings.ASKBOT_URL):
        template_name = 'errors/500.html'
    else:
        template_name = '500.html'

    return defaults.page_not_found(request, template_name=template_name)

In urls.py:

handler500 = 'your_app.views.view_500'

We move our error templates for all apps to 'error/' subfolder in template folder. In this case askbot template loader can't find it and templates will be loaded using next loader in TEMPLATE_LOADERS - standard Django loader. Thus, we have separate error templates for our apps and for askbot. But it's still an ugly hack :)

danila_a's avatar
1
danila_a
answered 2013-01-29 03:15:51 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments