File: kid_handler.cgi

package info (click to toggle)
kid 0.6.3-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 588 kB
  • ctags: 588
  • sloc: python: 2,447; makefile: 5; xml: 4
file content (31 lines) | stat: -rwxr-xr-x 756 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python
"""A very very early attempt at a CGI based handler for Kid templates."""

import sys
# make sure the kid modules are available 
# sys.path.append(os.path.dirname(__file__))

import os
import cgi
import cgitb; cgitb.enable()

import kid
f = os.environ['PATH_TRANSLATED']
template = kid.Template(file=f)

def default_cgi_main():
  dic = template.__dict__
  media_type = dic.get('media_type', 'text/html')
  charset = dic.get('encoding', 'utf-8')
  print 'Content-Type: %s;charset=%s' % (media_type, charset)
  print ''
  
try:
  cgi_main = module.cgi_main   
except AttributeError:
  cgi_main = default_cgi_main

cgi_main()
form = cgi.FieldStorage()
for part in template.generate(output=sys.stdout, context=form):
  sys.stdout.write(part)