All templates that get rendered by TurboGears have access to some basic variables automatically. The variables are defined in the stdvars function in turbogears.view. They provide conveniences for identifying the user's browser, plus common template tasks. See the stdvars documentation (TODO: link) for the complete list.
In order to avoid name collisions with your own template variables, all of the predefined variables are found in "tg". For example, the user agent is found in tg.useragent.
One in particular that's worth noting is tg.ipeek, which lets you look at the first item of an iterator without actually consuming it from the iterator. This comes in handy when you have an iterator that might be empty. If it is empty, you may not display a whole block from your template. Here's an example:
When you have a list, you don't need to use tg.ipeek. But, when all you have is an iterator, this is a handy tool.
If you have site-wide variables that you would like available in your templates, you can add a callable to turbogears.view.variable_providers. This will be called with a dictionary that is already set up with the TurboGears standard variables. If you want the current time available in all of your templates, you can just add this to a module: