On Tue, Feb 10, 2009 at 11:42 PM, Eric Lemoine <[email protected]> wrote:
>
> Hi
>
> Some simple questions related to the "debug" var defined in the
> development.ini file:
>
> (1) Why is this variable defined using "set"? Other variables in the
> development.ini file aren't defined using "set", so what does make
> "debug" a special case?

That's not very well documented.  'debug' is inherited from the
DEFAULT section.  Using 'set' overrides it in the default section.

> (2) I need to test whether the debug var is set in a Mako template, I
> do it as follows:
>
> % if config["debug"]:
> blabla
> % else:
> blabla
> % endif
>
> is it the correct way? Or should I use asbool(config["debug"]) as done
> in middleware.py? If so how can I make the asbool function available
> in my template?

<%!   from paste.deploy.converters import asbool   %>

I personally validate and change the types of the config vars in
environment.py.  That way if there's a missing or incorrect variable
it'll cause an error at startup rather than only in certain request
situations.

> I didn't do any particular to be able to access the Pylons "config"
> object from my template, how does Pylons make it available for me?

All the Pylons context variables are put in the template namespace
implicitly.  c, app_globals (g), config, session, cache, url.  And h
of course.

-- 
Mike Orr <[email protected]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to