Mercurial > treepkg
annotate contrib/sawmill/web/index.py @ 460:10d4cbffcc07
corrected link back to overview in detail view of sawmill
author | Sascha Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 27 Aug 2010 09:50:04 +0000 |
parents | 333232953771 |
children | d8012571f9e1 |
rev | line source |
---|---|
452
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
1 # -*- coding: UTF-8 -*- |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
2 # |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
3 # Copyright (C) 2010 by Intevation GmbH |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
4 # Authors: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
5 # Sascha L. Teichmann <sascha.teichmann@intevation.de> |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
6 # |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
7 # This program is free software under the GPL (>=v2) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
8 # Read the file COPYING coming with the software for details. |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
9 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
10 from mod_python import psp |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
11 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
12 import os |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
13 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
14 from lxml import etree |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
15 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
16 TREEPKG_DIR = os.path.join(os.path.dirname(__file__), "treepkgs") |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
17 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
18 def index(req): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
19 req.content_type = 'text/html;charset=utf-8' |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
20 template = psp.PSP(req, filename='templates/overview.html') |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
21 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
22 descriptions = [] |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
23 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
24 for f in os.listdir(TREEPKG_DIR): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
25 d = os.path.join(TREEPKG_DIR, f) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
26 if not os.path.isdir(d): continue |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
27 treepkg_xml = os.path.join(d, "treepkg.xml") |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
28 if not os.path.isfile(treepkg_xml): continue |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
29 xml = None |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
30 try: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
31 xml = open(treepkg_xml, "rb") |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
32 dom = etree.parse(xml) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
33 finally: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
34 if xml: xml.close() |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
35 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
36 description = ''.join(dom.xpath("//description/text()")) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
37 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
38 descriptions.append((os.path.basename(d), description)) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
39 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
40 template.run({'descriptions': descriptions}) |