[Mpuls-commits] r3131 - in base/trunk: . mpulsweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Jul 2 21:18:01 CEST 2010
Author: bh
Date: 2010-07-02 21:18:00 +0200 (Fri, 02 Jul 2010)
New Revision: 3131
Modified:
base/trunk/ChangeLog
base/trunk/mpulsweb/model/appointment.py
Log:
* mpulsweb/model/appointment.py (Appointment.store)
(Appointment.delete): Use DB.execute to execute the database
transactions
Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog 2010-07-02 19:13:21 UTC (rev 3130)
+++ base/trunk/ChangeLog 2010-07-02 19:18:00 UTC (rev 3131)
@@ -1,5 +1,11 @@
2010-07-02 Bernhard Herzog <bh at intevation.de>
+ * mpulsweb/model/appointment.py (Appointment.store)
+ (Appointment.delete): Use DB.execute to execute the database
+ transactions
+
+2010-07-02 Bernhard Herzog <bh at intevation.de>
+
* mpulsweb/model/appointment.py (Appointment.store): Use
log.exception instead of log.error to log exceptions and add a log
message
Modified: base/trunk/mpulsweb/model/appointment.py
===================================================================
--- base/trunk/mpulsweb/model/appointment.py 2010-07-02 19:13:21 UTC (rev 3130)
+++ base/trunk/mpulsweb/model/appointment.py 2010-07-02 19:18:00 UTC (rev 3131)
@@ -391,22 +391,16 @@
self.case_id = data.get('case_id', self.case_id)
def store(self):
- conn, cur = None, None
- fields = {'id': self.id, 'case_id': self.case_id, 'type': self.type,
- 'title': self.title, 'description': self.description,
- 'start_date': self.start_date, 'end_date': self.end_date,
- }
try:
- conn = db.getConnection()
- cur = conn.cursor()
- cur.execute(self.store_sql, fields)
- conn.commit()
+ fields = {'id': self.id, 'case_id': self.case_id, 'type': self.type,
+ 'title': self.title, 'description': self.description,
+ 'start_date': self.start_date, 'end_date': self.end_date,
+ }
+ db.execute(self.store_sql, fields)
return True
except Exception:
log.exception("Error while storing appointment %r for case %r"
% (self.id, self.case_id))
- finally:
- db.recycleConnection(conn, cur)
return False
def isGlobal(self):
@@ -416,16 +410,8 @@
return self.type == 1
def delete(self):
- conn, cur = None, None
- try:
- conn = db.getConnection()
- cur = conn.cursor()
- cur.execute(self.delete_sql, {'id': self.id})
- conn.commit()
- return True
- finally:
- db.recycleConnection(conn, cur)
- return False
+ db.execute(self.delete_sql, {'id': self.id})
+ return True
class GlobalAppointment(Appointment):
More information about the Mpuls-commits
mailing list