According to the cook book, a site layout template can use $if content.somevar.
However, I get
<type 'exceptions.AttributeError'> at /
I've tried this suggestion from a (rather old) Google Groups post:
$if hasattr(content, 'somevar')
But that results in
<type 'exceptions.NameError'> at /
global name 'hasattr' is not defined
I thought this might be a problem with security, but the doc says a SecurityException should be thrown in that case. If I change the code to use getattr (which is explicitly mentioned as forbidden in the docs), I get the same error (does that mean that the docs are off, and no SecurityException is thrown?).
Now, as a workaround, you can of course write $var somevar: in the page template, but that completely defeats the purpose of $if content.somevar in the base template, as you could just print $content.somevar if it's never unset.
By the way:
>>> import web