[Erp5-report] r34821 daniele - in /erp5/trunk/products/ERP5: Document/ Tool/
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Apr 27 14:35:23 CEST 2010
Author: daniele
Date: Tue Apr 27 14:35:19 2010
New Revision: 34821
URL: http://svn.erp5.org?rev=34821&view=rev
Log:
Change mysql error to only check if the table not exists and
change the bad security on the methods, thanks you Jerome.
Modified:
erp5/trunk/products/ERP5/Document/IdGenerator.py
erp5/trunk/products/ERP5/Document/SQLNonContinuousIncreasingIdGenerator.py
erp5/trunk/products/ERP5/Tool/IdTool.py
Modified: erp5/trunk/products/ERP5/Document/IdGenerator.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/IdGenerator.py?rev=34821&r1=34820&r2=34821&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/IdGenerator.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/IdGenerator.py [utf8] Tue Apr 27 14:35:19 2010
@@ -105,7 +105,7 @@
return specialise.getLatestVersionValue().generateNewIdList(id_group=id_group, \
id_count=id_count, default=default)
- security.declareProtected(Permissions.AccessContentsInformation,
+ security.declareProtected(Permissions.ModifyPortalContent,
'initializeGenerator')
def initializeGenerator(self):
"""
@@ -119,7 +119,7 @@
self.getReference()
specialise.getLatestVersionValue().initializeGenerator()
- security.declareProtected(Permissions.AccessContentsInformation,
+ security.declareProtected(Permissions.ModifyPortalContent,
'clearGenerator')
def clearGenerator(self):
"""
Modified: erp5/trunk/products/ERP5/Document/SQLNonContinuousIncreasingIdGenerator.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/SQLNonContinuousIncreasingIdGenerator.py?rev=34821&r1=34820&r2=34821&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/SQLNonContinuousIncreasingIdGenerator.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/SQLNonContinuousIncreasingIdGenerator.py [utf8] Tue Apr 27 14:35:19 2010
@@ -34,6 +34,7 @@
from Products.ERP5Type.Utils import ScalarMaxConflictResolver
from Products.ERP5.Document.IdGenerator import IdGenerator
from _mysql_exceptions import ProgrammingError
+from MySQLdb.constants.ER import NO_SUCH_TABLE
from zLOG import LOG, INFO
class SQLNonContinuousIncreasingIdGenerator(IdGenerator):
@@ -86,7 +87,9 @@
new_id = result_query[0]['LAST_INSERT_ID()']
# Commit the changement of new_id
commit_method()
- except ProgrammingError:
+ except ProgrammingError, error:
+ if error[0] != NO_SUCH_TABLE:
+ raise
# If the database not exist, initialise the generator
self.initializeGenerator()
if self.getStoredInZodb():
@@ -142,7 +145,9 @@
'idTool_zGetValueList could not be found.'
try:
get_value_list()
- except ProgrammingError:
+ except ProgrammingError, error:
+ if error[0] != NO_SUCH_TABLE:
+ raise
drop_method = getattr(portal, 'IdTool_zDropTable', None)
create_method = getattr(portal, 'IdTool_zCreateEmptyTable', None)
if None in (drop_method, create_method):
@@ -161,9 +166,8 @@
'idTool_zGetLastId and/or idTool_zSetLastId could not be found.'
storage = self.getStoredInZodb()
# Recovery last_max_id_dict datas in zodb if enabled and is in mysql
- if len(self.last_max_id_dict) != 0:
- dump_dict = self.last_max_id_dict
- elif getattr(portal_ids, 'dict_length_ids', None) is not None:
+ if len(self.last_max_id_dict) == 0 and \
+ getattr(portal_ids, 'dict_length_ids', None) is not None:
dump_dict = portal_ids.dict_length_ids
for id_group, last_id in dump_dict.items():
last_insert_id = get_last_id_method(id_group=id_group)
@@ -172,7 +176,7 @@
if last_insert_id > last_id.value:
# Check value in dict
if storage and (not self.last_max_id_dict.has_key(id_group) or \
- self.last_max_id_dict.has_key[id_group] != last_insert_id):
+ self.last_max_id_dict[id_group].value < last_insert_id):
self.last_max_id_dict[id_group] = ScalarMaxConflictResolver(last_insert_id)
self.last_max_id_dict[id_group].set(last_insert_id)
continue
Modified: erp5/trunk/products/ERP5/Tool/IdTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/IdTool.py?rev=34821&r1=34820&r2=34821&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/IdTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Tool/IdTool.py [utf8] Tue Apr 27 14:35:19 2010
@@ -100,8 +100,6 @@
raise KeyError, 'The generator %s is not present' % (reference,)
return id_last_generator
- security.declareProtected(Permissions.AccessContentsInformation,
- 'getLatestGeneratorValue')
def _getLatestGeneratorValue(self, id_generator):
"""
Return the last generator with the reference
More information about the Erp5-report
mailing list