[Mpuls-commits] r4514 - base/trunk/mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jan 21 14:21:42 CET 2011


Author: torsten
Date: 2011-01-21 14:21:41 +0100 (Fri, 21 Jan 2011)
New Revision: 4514

Modified:
   base/trunk/mpulsweb/lib/helpers.py
Log:
* mpulsweb/lib/helpers.py: New function to render links to switch
	between different datasets.


Modified: base/trunk/mpulsweb/lib/helpers.py
===================================================================
--- base/trunk/mpulsweb/lib/helpers.py	2011-01-21 13:19:57 UTC (rev 4513)
+++ base/trunk/mpulsweb/lib/helpers.py	2011-01-21 13:21:41 UTC (rev 4514)
@@ -1,3 +1,4 @@
+## -*- coding: utf-8 -*-
 # Copyright 2007, 2008, 2010 Intevation GmbH, Germany, <info at intevation.de>
 #
 # This file is part of mpuls WASKA (CoMPUter-based case fiLeS -
@@ -33,6 +34,7 @@
 import logging
 import re
 import datetime
+import ConfigParser, os
 from string import printable
 from xml.sax.saxutils import quoteattr
 
@@ -212,6 +214,28 @@
 def get_app_title():
     return config.get('mpuls.app.title')
 
+def get_urls_for_other_datasets():
+    apps = re.compile('app:')
+    parser = ConfigParser.ConfigParser()
+    path = os.path.join(config['here'], config['__file__'])
+    parser.readfp(open(path))
+    l = []
+    for sec in parser.sections():
+        if apps.match(sec):
+            try:
+                name = parser.get(sec, 'mpuls.app.name')
+                url = parser.get(sec, 'mpuls.app.url')
+                l.append((name, url))
+            except:
+                pass
+    if l > 1: # Administration is only neede if there are more than one datasets
+        try:
+            path = parser.get('app:redirector', 'location')
+            if request.url.find(path) > 0 and hasRole(['admin']):
+                l.append((_('Userpersmissions'), os.path.join(path, 'permissions')))
+        except:
+            pass
+    return l 
 
 # Helper functions to get some information about the logged in user
 



More information about the Mpuls-commits mailing list