Commit 019d55c5 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Factorize try/except in setConfiguration.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1023 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent ce44e838
......@@ -185,23 +185,23 @@ class MySQLDatabaseManager(DatabaseManager):
return None
def setConfiguration(self, key, value):
self.begin()
try:
q = self.query
e = self.escape
key = e(str(key))
value = e(str(value))
q("""REPLACE INTO config VALUES ('%s', '%s')""" % (key, value))
except:
self.rollback()
raise
self.commit()
def getUUID(self):
return self.getConfiguration('uuid')
def setUUID(self, uuid):
self.begin()
try:
self.setConfiguration('uuid', uuid)
except:
self.rollback()
raise
self.commit()
def getNumPartitions(self):
n = self.getConfiguration('partitions')
......@@ -209,13 +209,7 @@ class MySQLDatabaseManager(DatabaseManager):
return int(n)
def setNumPartitions(self, num_partitions):
self.begin()
try:
self.setConfiguration('partitions', num_partitions)
except:
self.rollback()
raise
self.commit()
def getNumReplicas(self):
n = self.getConfiguration('replicas')
......@@ -223,37 +217,19 @@ class MySQLDatabaseManager(DatabaseManager):
return int(n)
def setNumReplicas(self, num_replicas):
self.begin()
try:
self.setConfiguration('replicas', num_replicas)
except:
self.rollback()
raise
self.commit()
def getName(self):
return self.getConfiguration('name')
def setName(self, name):
self.begin()
try:
self.setConfiguration('name', name)
except:
self.rollback()
raise
self.commit()
def getPTID(self):
return self.getConfiguration('ptid')
def setPTID(self, ptid):
self.begin()
try:
self.setConfiguration('ptid', ptid)
except:
self.rollback()
raise
self.commit()
def getPartitionTable(self):
q = self.query
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment