Ask Your Question
2

`'settings' is undefined` in custom template?

asked 2012-02-18 10:53:36 -0500

piskvorky gravatar image piskvorky
350 9 4 19

updated 2012-02-18 10:56:46 -0500

I see the askbot templates use constructs like {% if settings.BLABLA %}.

From what I understand, the settings var should always be present, from askbot.context.application_settings, right?

But when I try to use {% if settings.XYZ %} in my own skin widgets, I get

Exception Type: UndefinedError
Exception Value:   'settings' is undefined

How can that be? I would post more info but don't know what could be relevant to this.

delete close flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-02-18 11:06:20 -0500

Evgeny gravatar image Evgeny flag of Chile
11009 50 84 182
http://askbot.org/

I did disable settings injection into non-askbot views to reduce impact of askbot on other apps. Just add template settings directly in your view. If you are not comfortable with handpicking the settings for the templates - copy a snippet from /askbot/context.py to load all the livesettings at once.

IMO it was a poor idea to put settings into the template context processor, because it slows down everything in the django project even apps that have nothing to do with askbot. I am thinking of completely moving to manually populating the template context in each view.

We are now focusing on improving performance of the app now, so cutting that fat where possible.

link publish delete flag offensive edit

Comments

That makes sense in the future, but how did you disable it now? I still see askbot.context.application_settings in the context processors (using askbot from jan 11).

piskvorky ( 2012-02-18 12:01:34 -0500 )edit

hah, yes disabling only works if askbot is installed on a sub-url like /forum. For you all you are missing is probably the RequestContext for the view, no?

Evgeny ( 2012-02-18 12:07:43 -0500 )edit

No, actually I found the problem was with macros -- the context is not being passed. For now I replaced the macros indirection with a simple direct {% include %}, I'll have to read more about how macros work later.

piskvorky ( 2012-02-18 12:34:02 -0500 )edit

In macros you only see the variables that you give explicitly. They do not receive the template context, so this is an expected behavior.

Evgeny ( 2012-02-19 11:32:30 -0500 )edit

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Reliable Askbot Hosting

Create your Q&A site at askbot.com. Managed Askbot hosting at just $15/mo. Dedicated hosting, support contracts, consulting services.

create your Q&A site
30 days free trial

Question tools

Follow

subscribe to rss feed

Stats

Asked: 2012-02-18 10:53:36 -0500

Seen: 122 times

Last updated: Feb 18 '12