From eeaa41e2ccf2a34af51b850b8cc632260f70588f Mon Sep 17 00:00:00 2001 From: ced <> Date: Thu, 30 Aug 2007 14:22:09 +0000 Subject: [PATCH] Don't commit in the middle of loading modules bzr revid: ced-aa64aa32c325a479eaaac0be7a33c6986eedd96e --- bin/addons/__init__.py | 3 +-- bin/tools/convert.py | 26 +++++++------------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index 3174eb88d19..101698b8852 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -217,7 +217,6 @@ def load_module_graph(cr, graph, status=None, **kwargs): new_query = ' '.join(query.split()) if new_query: cr.execute(new_query) - cr.commit() else: tools.convert_xml_import(cr, m, tools.file_open(opj(m, filename)).read(), idref, mode=mode, **kwargs) if hasattr(package, 'demo') or (package_demo and package_state != 'installed'): @@ -232,7 +231,7 @@ def load_module_graph(cr, graph, status=None, **kwargs): cr.execute('update ir_module_module set demo=%s where name=%s', (True, package.name)) package_todo.append(package.name) cr.execute("update ir_module_module set state='installed' where state in ('to upgrade', 'to install') and name=%s", (package.name,)) - cr.commit() + cr.commit() statusi+=1 pool = pooler.get_pool(cr.dbname) diff --git a/bin/tools/convert.py b/bin/tools/convert.py index 3bd94661f01..4f6fb9a075b 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -13,14 +13,6 @@ import netsvc from config import config import logging -# Number of imported lines between two commit (see convert_csv_import()): -COMMIT_STEP = 500 - - - -# Number of imported lines between two commit (see convert_csv_import()): -COMMIT_STEP = 500 - class ConvertError(Exception): def __init__(self, doc, orig_excpt): @@ -589,7 +581,6 @@ class xml_import(object): self.logger.notifyChannel("init", netsvc.LOG_INFO, '\n'+rec.toxml()) self.cr.rollback() raise - self.cr.commit() return True def __init__(self, cr, module, idref, mode, report=assertion_report(), noupdate = False): @@ -616,13 +607,13 @@ class xml_import(object): 'act_window': self._tag_act_window, } -# -# Import a CSV file: -# quote: " -# delimiter: , -# encoding: UTF8 -# +CSV_STEP = 500 + def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', noupdate=False): + '''Import csv file : + quote: " + delimiter: , + encoding: utf-8''' if not idref: idref={} model = ('.'.join(fname.split('.')[:-1]).split('-'))[0] @@ -642,14 +633,11 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', n datas = [] for line in reader: datas.append( map(lambda x:x.decode('utf8').encode('utf8'), line)) - if len(datas) > COMMIT_STEP: + if len(datas) > CSV_STEP: pool.get(model).import_data(cr, uid, fields, datas,mode, module,noupdate) - cr.commit() datas=[] - if datas: pool.get(model).import_data(cr, uid, fields, datas,mode, module,noupdate) - cr.commit() # # xml import/export