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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Nov 2 16:23:37 CET 2011


Author: torsten
Date: 2011-11-02 16:23:36 +0100 (Wed, 02 Nov 2011)
New Revision: 5525

Modified:
   base/trunk/mpulsweb/lib/helpers.py
Log:
Added new method get_TagSetter wihich returns a TagSetter object. This is
object is need in two places in mpuls yet so the method to build this object
was moved into helpers.


Modified: base/trunk/mpulsweb/lib/helpers.py
===================================================================
--- base/trunk/mpulsweb/lib/helpers.py	2011-11-02 15:06:46 UTC (rev 5524)
+++ base/trunk/mpulsweb/lib/helpers.py	2011-11-02 15:23:36 UTC (rev 5525)
@@ -35,6 +35,7 @@
 import os
 import datetime
 
+from libmpuls.service.tags import TagSetterConfig, TagSetter
 from pylons import config, g, request, url
 from mpulsweb.lib.translation import _
 
@@ -46,7 +47,8 @@
 
 from formed.renderer.helpers import tag
 
-from mpulsweb.lib.security import hasRole, getKAName
+from mpulsweb.lib.security import hasRole, getKAName, \
+get_db_parameters
 
 from mpulsweb.lib.helper.filters import shorten, NA
 
@@ -141,6 +143,26 @@
     return format_time(datetime.datetime.now()
                        + datetime.timedelta(seconds=timeout - 120), True)
 
+def get_TagSetter(user, config):
+    db_parameters = get_db_parameters(user.login, user.password,
+                                      config.get('mpuls.db.host'),
+                                      config.get('mpuls.db.port'),
+                                      config.get('mpuls.db.database'),
+                                      config.get('mpuls.db.user'))
+
+    #TODO:
+    # 1. Use established db-connection
+    # 2. Do create (and parse config) a TagSetter every time.
+    tagconfig = TagSetterConfig(g.taggingConfFile,
+                                username=db_parameters['user'],
+                                password=db_parameters['password'],
+                                database=db_parameters['database'],
+                                host=db_parameters['host'],
+                                port=db_parameters['port'],
+                                caseid=None)
+    return TagSetter(tagconfig)
+
+
 def getHelp(help_id):
     '''
     Returns a HTML link with a help icon if help is present for help_id. Else



More information about the Mpuls-commits mailing list