Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration of genshi variable lookup mechanism #13

Open
rslinckx opened this issue Oct 27, 2011 · 1 comment
Open

Allow configuration of genshi variable lookup mechanism #13

rslinckx opened this issue Oct 27, 2011 · 1 comment

Comments

@rslinckx
Copy link

Genshi allows different behaviors when looking up variables in a template. By default this is 'strict' meaning an undefined variable will trigger an exception when rendering the template.

They also have an optional 'lenient' mechanism which results in an empty string or false value when such a variable is found. This setting is sometimes more appropriate in production.

To configure this you can pass a variable_lookup=xxx to the template loader where xxx is either a string or a class.

Currently I use the following code to set it:

genshi = Genshi(app)
genshi.template_loader.variable_lookup = 'lenient'

It would be nicer if i could configure it using a config variable app.config['GENSHI_VARIABLE_LOOKUP'] for example.

I didn't find any other config key in the current code, so i'm not sure if it's an acceptable approach ?

@dag
Copy link
Owner

dag commented Oct 27, 2011

It feels dirty, but I suppose you have a point about production where fault-tolerance might have a higher priority than correctness. In the rewrite branch this would be easy to add yourself via subclassing, but maybe there should be a config option. I'll have to think on it and discuss with Armin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants