2 # $Id: CGITemplate.py,v 1.6 2006/01/29 02:09:59 tavis_rudd Exp $
3 """A subclass of Cheetah.Template for use in CGI scripts.
6 #extends Cheetah.Tools.CGITemplate
10 Usage in a template inheriting a Python class:
12 #extends MyPythonClass
17 from Cheetah.Tools import CGITemplate
18 class MyPythonClass(CGITemplate):
19 def cgiHeadersHook(self):
20 return "Content-Type: text/html; charset=koi8-r\n\n"
22 To read GET/POST variables, use the .webInput method defined in
23 Cheetah.Utils.WebInputMixin (available in all templates without importing
24 anything), use Python's 'cgi' module, or make your own arrangements.
26 This class inherits from Cheetah.Template to make it usable in Cheetah's
27 single-inheritance model.
31 ================================================================================
32 Author: Mike Orr <iron@mso.oz.net>
33 License: This software is released for unlimited distribution under the
34 terms of the MIT license. See the LICENSE file.
35 Version: $Revision: 1.6 $
36 Start Date: 2001/10/03
37 Last Revision Date: $Date: 2006/01/29 02:09:59 $
39 __author__
= "Mike Orr <iron@mso.oz.net>"
40 __revision__
= "$Revision: 1.6 $"[11:-2]
43 from Cheetah
.Template
import Template
45 class CGITemplate(Template
):
46 """Methods useful in CGI scripts.
48 Any class that inherits this mixin must also inherit Cheetah.Servlet.
53 """Outputs the CGI headers if this is a CGI script.
55 Usage: $cgiHeaders#slurp
56 Override .cgiHeadersHook() if you want to customize the headers.
59 return self
.cgiHeadersHook()
63 def cgiHeadersHook(self
):
64 """Override if you want to customize the CGI headers.
66 return "Content-type: text/html\n\n"
70 """Is this a CGI script?
72 env
= os
.environ
.has_key('REQUEST_METHOD')
73 wk
= self
._CHEETAH
__isControlledByWebKit
78 # vim: shiftwidth=4 tabstop=4 expandtab