4 messages in com.googlegroups.pylons-discussRe: turning on "strict" mode in Genshi| From | Sent On | Attachments |
|---|---|---|
| Chris Curvey | 11 Mar 2008 13:07 | |
| Mike Orr | 11 Mar 2008 15:36 | |
| Chris Curvey | 14 Mar 2008 08:01 | |
| Mike Orr | 14 Mar 2008 08:52 |
| Subject: | Re: turning on "strict" mode in Genshi![]() |
|---|---|
| From: | Mike Orr (slug...@public.gmane.org) |
| Date: | 03/14/2008 08:52:36 AM |
| List: | com.googlegroups.pylons-discuss |
On Fri, Mar 14, 2008 at 10:02 AM, Chris Curvey
<ccur...@public.gmane.org> wrote:
On Mar 11, 6:36 pm, "Mike Orr"
<slug...@public.gmane.org> wrote:
On Tue, Mar 11, 2008 at 1:08 PM, Chris Curvey
<ccur...@public.gmane.org> wrote:
I'm using Genshi for my templating language in my Pylons project, but I can't figure out how to turn on "strict" mode (so that it will fail loudly when I mistype a variable name).
Anyone got the recipe?
If you're talking about 'c' variables, put this in environment.py:
config["pylons.strict_c"] = True
If you're talking about something Genshi-specific, I don't know.
I was looking for a way to turn on "strict" like this:
http://genshi.edgewall.org/wiki/Documentation/0.4.x/templates.html#error-handling
And "pylons.strict_c" seems to work, so long as it's the first level deep, but not beyond that. For example, if I reference "c.misspelled_var", then I get a traceback (hooray!). But if I reference "c.well_named_var.misspelled_attribute", then the value just doesn't show up.
Oh well, it's a step in the right direction. Thanks for the help.
-Chris
P.S. I tried setting config['genshi.lookup_errors'] = 'strict' in my environment.py, but that did not seem to do anything.
That definitely won't work. You can try that template options variable in environment.py, or look at the source code of the Buffet plugin (called tgsupport or something like that, either in Genshi itself or in TurboGenshi) to see which engine options it recognizes. If it doesn't recognize the options you need, you can:
- Write an equivalent plugin that does. You'll have to give it a different entry point name (not "genshi"), and reference that name in middleware.py.
- Write your own render() function that bypasses Buffet entirely and does things the native Genshi way. The Pylons development version should have a simple render function as an example, and this is expected to replace Buffet in Pylons1.0.
-- Mike Orr <slug...@public.gmane.org>




