summaryrefslogtreecommitdiff
path: root/pagehandler.py
blob: 477f54030ad5cfed79e5fc9905c592bdbc7a1a3b (plain)
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
#!/usr/bin/python
# -*- coding: utf-8 -*-

# main (mod_python) request handler for patch-tracking system
# this handler file basically farms out all its work to the ReqHandler
# module, which in turn splits up the request URI and acts accordingly.

from mod_python import apache
import os
import sys

def handler(req):
  # the apache config sets a hint of where we are installed, which is
  # needed in mod_python since cwd is not automatically set
  try:
    sys.path+=[req.subprocess_env["PT_INSTALLROOT"]]
    os.chdir(req.subprocess_env["PT_INSTALLROOT"])
  except:
    pass

  import patchtracker.ReqHandler as ReqHandler
  ReqHandler.Client.req = req

  req.write(ReqHandler.CmdHandler(req).output())
  return apache.OK