Cheetah.Tools.CGITemplate module

A subclass of Cheetah.Template for use in CGI scripts.

Usage in a template:
#extends Cheetah.Tools.CGITemplate #implements respond $cgiHeaders#slurp

Usage in a template inheriting a Python class: 1. The template

#extends MyPythonClass #implements respond $cgiHeaders#slurp
  1. The Python class

    from Cheetah.Tools import CGITemplate class MyPythonClass(CGITemplate):

    def cgiHeadersHook(self):

    return “Content-Type: text/html; charset=koi8-r

To read GET/POST variables, use the .webInput method defined in Cheetah.Utils.WebInputMixin (available in all templates without importing anything), use Python’s ‘cgi’ module, or make your own arrangements.

This class inherits from Cheetah.Template to make it usable in Cheetah’s single-inheritance model.

class Cheetah.Tools.CGITemplate.CGITemplate(source=None, namespaces=None, searchList=None, file=None, filter='RawOrEncodedUnicode', filtersLib=<module 'Cheetah.Filters' from '/home/phd/current/projects/cheetah3/cheetah3/Cheetah/Filters.py'>, errorCatcher=None, compilerSettings=Unspecified, _globalSetVars=None, _preBuiltSearchList=None)

Bases: Cheetah.Template.Template

Methods useful in CGI scripts.

Any class that inherits this mixin must also inherit Cheetah.Servlet.

cgiHeaders()

Outputs the CGI headers if this is a CGI script.

Usage: $cgiHeaders#slurp Override .cgiHeadersHook() if you want to customize the headers.

cgiHeadersHook()

Override if you want to customize the CGI headers.

isCgi()

Is this a CGI script?