[Mpuls-commits] r1040 - wasko/branches/2.0/waskaweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Feb 1 11:25:16 CET 2010
Author: torsten
Date: 2010-02-01 11:25:15 +0100 (Mon, 01 Feb 2010)
New Revision: 1040
Modified:
wasko/branches/2.0/waskaweb/controllers/caselifetime.py
Log:
* waskaweb/controllers/caselifetime.py (DataExtractor.loadData): Moved
from model.datapage. DataExtractor is only used in connection with
"Neuaufnahme" and "Wiederaufnahme". Changed import.
Modified: wasko/branches/2.0/waskaweb/controllers/caselifetime.py
===================================================================
--- wasko/branches/2.0/waskaweb/controllers/caselifetime.py 2010-02-01 10:18:20 UTC (rev 1039)
+++ wasko/branches/2.0/waskaweb/controllers/caselifetime.py 2010-02-01 10:25:15 UTC (rev 1040)
@@ -17,7 +17,6 @@
from waskaweb.model.case import CaseFactory
from waskaweb.model.logbook import Logbook, LogbookEntry
-from waskaweb.model.datapage import DataExtractor
from waskaweb.controllers.CaseBase import CasebaseController
from formed.instance.backends.postgres import DBFactory as InstanceFactory
@@ -118,8 +117,46 @@
return values, errors
+class DataExtractor(object):
+ def __init__(self):
+ self.data = None
+ def loadData(self, ds_id, keys):
+ cur, con = None, None
+
+ try:
+ con = db.getConnection()
+ cur = con.cursor()
+ select = "SELECT %s FROM master_tbl_view WHERE id = %%(ds_id)s" % \
+ ", ".join(keys)
+ cur.execute(select, { 'ds_id': ds_id })
+ row = cur.fetchone()
+ if not row:
+ raise Exception("No such data set: %d" % ds_id)
+
+ self.data = dict(zip([d[0] for d in cur.description], row))
+ finally:
+ db.recycleConnection(con, cur)
+
+ def storeData(self, ds_id):
+
+ update = "UPDATE master_tbl_view SET %s WHERE id = %%(ds_id)s" % \
+ ", ".join(["%s = %%(%s)s" % (n, n) for n in self.data.iterkeys()])
+
+ try:
+ con = db.getConnection()
+ cur = con.cursor()
+ values = self.data or {}
+ values['ds_id'] = ds_id
+ cur.execute(update, values)
+ con.commit()
+ finally:
+ db.recycleConnection(con, cur)
+
+
+
+
def create_logbook(id=None, header=None, text=None):
if id is None:
id = session['case'].id
More information about the Mpuls-commits
mailing list