[Mpuls-commits] r3300 - base/trunk/mpulsweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Aug 2 16:14:25 CEST 2010
Author: torsten
Date: 2010-08-02 16:14:24 +0200 (Mon, 02 Aug 2010)
New Revision: 3300
Modified:
base/trunk/mpulsweb/model/case.py
Log:
* mpulsweb/model/case.py (MpulsCase.checkValidity): Added function to
implement application based tagging based on libmpuls-tagging
functionality.
Modified: base/trunk/mpulsweb/model/case.py
===================================================================
--- base/trunk/mpulsweb/model/case.py 2010-08-02 13:31:06 UTC (rev 3299)
+++ base/trunk/mpulsweb/model/case.py 2010-08-02 14:14:24 UTC (rev 3300)
@@ -34,6 +34,7 @@
import psycopg2.extras
+from pylons import config
from mpulsweb.lib.translation import _
from formed.meta.data import RepeatNode, DateLeaf, IntLeaf, TextLeaf, ChoiceNode
@@ -41,11 +42,14 @@
from formed.instance.backends.xmlimport import XMLImporter, XMLImportException
from formed.instance.tree import SetDataException
+from libmpuls.service.tags import TagSetterConfig, TagSetter
+
from mpulsweb.lib.base import g, h, session
from mpulsweb.lib.export import XLSExport, CSVExport
from mpulsweb.lib.anonymize import determineAnonymizedCaseEndPhase
from mpulsweb.lib.helpers import ensure_unicode, format_date
from mpulsweb.lib.db import PostgresDBInterface, db
+from mpulsweb.lib.security import getDbName
from mpulsweb.model.document import listDocuments
from mpulsweb.model.statement import PrivacyStatement
@@ -821,6 +825,30 @@
self.tags = []
return self.tags
+ def checkValidity(self):
+ '''Will check validity and set tags based on configuration in tagging.xml'''
+
+ user = session['USER_AUTHORIZED']
+ host = config.get('mpuls.db.host')
+ port = config.get('mpuls.db.port')
+ db = config.get('mpuls.db.database')
+ db_user = config.get('mpuls.db.user')
+ db_name = getDbName()
+ filename = config.get('mpuls.app.tagging')
+
+ tagconfig = TagSetterConfig(
+ filename,
+ username=db_user % (db_name, user.login),
+ password=user.password,
+ database=db % db_name,
+ host=host,
+ port=port,
+ caseid=self.id)
+ setter = TagSetter(tagconfig)
+
+ log.debug('Tagging case: %s' % self.id)
+ setter.perform(self.id)
+
def getValidity(self):
'''Will return the id of the max validity based on set tags'''
tags = set(self.getTags())
More information about the Mpuls-commits
mailing list