[Mpuls-commits] r3134 - in base/trunk: . mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jul 2 21:32:01 CEST 2010


Author: bh
Date: 2010-07-02 21:32:00 +0200 (Fri, 02 Jul 2010)
New Revision: 3134

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/model/case.py
Log:
* mpulsweb/model/case.py (MpulsCase.setEditor, MpulsCase.delete):
Use DB.execute to execute the database transactions


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-07-02 19:26:05 UTC (rev 3133)
+++ base/trunk/ChangeLog	2010-07-02 19:32:00 UTC (rev 3134)
@@ -1,5 +1,10 @@
 2010-07-02  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/model/case.py (MpulsCase.setEditor, MpulsCase.delete):
+	Use DB.execute to execute the database transactions
+
+2010-07-02  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/model/case.py (MpulsCaseState.setState)
 	(MpulsCaseState.setPhase): Use DB.execute to execute the database
 	transactions

Modified: base/trunk/mpulsweb/model/case.py
===================================================================
--- base/trunk/mpulsweb/model/case.py	2010-07-02 19:26:05 UTC (rev 3133)
+++ base/trunk/mpulsweb/model/case.py	2010-07-02 19:32:00 UTC (rev 3134)
@@ -844,20 +844,12 @@
 
     def setEditor(self, userid):
         """sets the editor of the case to the given userid"""
-        con, curr = None, None
         user = UserObject(userid)
-        fields = {'caseid': self.id, 'userid': userid}
-        con = db.getConnection()
-        cur = con.cursor()
         try:
-            cur.execute(SET_EDITOR_SQL, fields)
-            con.commit()
+            db.execute(SET_EDITOR_SQL, {'caseid': self.id, 'userid': userid})
         except Exception:
             log.exception("Error setting editor of case %r to %r"
                           % (self.id, userid))
-            con.rollback()
-        finally:
-            db.recycleConnection(con, cur)
         return self.editor
 
     def copy(self):
@@ -869,17 +861,11 @@
     def delete(self):
         """Deletes the case from data base. Returns True if deletion succseeds
         """
-        conn, cur = None, None
         try:
-            conn = db.getConnection()
-            cur = conn.cursor()
-            cur.execute(DELETE_CASE_SQL, {'id': self.id})
-            conn.commit()
+            db.execute(DELETE_CASE_SQL, {'id': self.id})
             return True
         except Exception:
             log.exception("Error trying to delete case %r" % (self.id,))
-        finally:
-            db.recycleConnection(conn, cur)
         return False
 
     def anonymize(self):



More information about the Mpuls-commits mailing list