[rhmessaging-commits] rhmessaging commits: r2829 - mgmt/trunk/mint/python/mint.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue Nov 18 11:12:15 EST 2008


Author: nunofsantos
Date: 2008-11-18 11:12:14 -0500 (Tue, 18 Nov 2008)
New Revision: 2829

Modified:
   mgmt/trunk/mint/python/mint/update.py
Log:
expand try/except/finally to be compatible with the python version in rhel5

Modified: mgmt/trunk/mint/python/mint/update.py
===================================================================
--- mgmt/trunk/mint/python/mint/update.py	2008-11-17 20:52:11 UTC (rev 2828)
+++ mgmt/trunk/mint/python/mint/update.py	2008-11-18 16:12:14 UTC (rev 2829)
@@ -161,18 +161,19 @@
 
       conn = model.dbConn.getConnection()
       try:
-        cursor = conn.cursor()
-        sql = model.generateSQLUpdate(sqlCls, attrs, id)
-        cursor.execute(sql)
-        if cursor.rowcount == 0:
-          sql = model.generateSQLInsert(sqlCls, attrs)
+        try:
+          cursor = conn.cursor()
+          sql = model.generateSQLUpdate(sqlCls, attrs, id)
           cursor.execute(sql)
-          log.debug("%s(%s) created", cls, id)
-        conn.commit()
-      except Exception, e:
-        conn.rollback()
-        print e
-        print_exc()
+          if cursor.rowcount == 0:
+            sql = model.generateSQLInsert(sqlCls, attrs)
+            cursor.execute(sql)
+            log.debug("%s(%s) created", cls, id)
+          conn.commit()
+        except Exception, e:
+          conn.rollback()
+          print e
+          print_exc()
       finally:
         conn.close()
 
@@ -188,23 +189,24 @@
           broker, dbObjId = model.managedBrokers[str(self.broker.getBrokerId())]
           if dbObjId == 0: 
             try:
-              conn = model.dbConn.getConnection()
-              cursor = conn.cursor()
-              sql = model.generateSQLSelectWhere(sqlCls, {"managed_broker": str(self.broker.getBrokerId())})
-              cursor.execute(sql)
-              rec = cursor.fetchone()
-              dbObjId = rec[0]  
+              try:  
+                conn = model.dbConn.getConnection()
+                cursor = conn.cursor()
+                sql = model.generateSQLSelectWhere(sqlCls, {"managed_broker": str(self.broker.getBrokerId())})
+                cursor.execute(sql)
+                rec = cursor.fetchone()
+                dbObjId = rec[0]  
 
-              cursor = conn.cursor()
-              sql = model.generateSQLUpdateWhere("broker_registration", {"broker_id": dbObjId}, \
-                                                     {"url": self.broker.getFullUrl()})
-              cursor.execute(sql)
-              conn.commit()
-              model.managedBrokers[str(self.broker.getBrokerId())] = (broker, dbObjId)
-            except Exception, e:
-              conn.rollback()
-              print e
-              print_exc()
+                cursor = conn.cursor()
+                sql = model.generateSQLUpdateWhere("broker_registration", {"broker_id": dbObjId}, \
+                                                       {"url": self.broker.getFullUrl()})
+                cursor.execute(sql)
+                conn.commit()
+                model.managedBrokers[str(self.broker.getBrokerId())] = (broker, dbObjId)
+              except Exception, e:
+                conn.rollback()
+                print e
+                print_exc()
             finally:
               conn.close()
     except:




More information about the rhmessaging-commits mailing list