1
0
Fork 0

- initial work on a mod_python based web frontend

- add logs to svn:ignore
- use psycopg2 in backend


git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@198 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
Jan Dittberner 2006-11-04 20:24:36 +00:00
parent 572b42a706
commit bf7992a600
6 changed files with 56 additions and 5 deletions

View file

View file

@ -0,0 +1,42 @@
from mod_python import apache, Session
from genshi.template import TemplateLoader, TemplateNotFound
from genshi import ParseError
def findtemplate(uri):
templates = {"/" : "index.xml"}
if uri in templates:
return templates[uri]
return None
def handler(req):
session = Session.Session(req)
try:
session['hits'] += 1
except:
session['hits'] = 1
session.save()
template = findtemplate(req.uri)
if template:
loader = TemplateLoader([req.document_root()])
try:
req.content_type = "text/html; charset=UTF-8"
tmpl = loader.load(template)
stream = tmpl.generate(title='Hello World: Reloaded',
hits=session['hits'])
pagebuffer = stream.render('xhtml')
except TemplateNotFound, tnf:
req.content_type = "text/plain; charset=UTF-8"
pagebuffer = str(tnf)
except ParseError, pe:
req.content_type = "text/plain; charset=UTF-8"
pagebuffer = str(pe)
#pagebuffer = "Hits: %d\n" % session['hits']
#pagebuffer += "Yippieh: I found %s -> %s!" % (req.uri, template)
req.write(pagebuffer)
return (apache.OK)
return (apache.HTTP_NOT_FOUND)

9
frontend/web/index.xml Normal file
View file

@ -0,0 +1,9 @@
<html>
<head>
<title>$title</title>
</head>
<body>
<h1>$title</h1>
<p>Hits: $hits</p>
</body>
</html>