From 795e755b42a8786e5bbe5f318b05d9943cd98a4c Mon Sep 17 00:00:00 2001 From: jas Date: Fri, 8 Oct 2010 18:50:28 +0530 Subject: [PATCH 1/3] [FIX] : base : import module as zip file bzr revid: jas@tinyerp.com-20101008132028-qzrac0xv1nu7z4ow --- bin/addons/__init__.py | 18 ++++++++++++++---- bin/addons/base/module/module.py | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index 08cc60c19bd..7db007b732f 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -270,7 +270,17 @@ def get_module_resource(module, *args): @return: absolute path to the resource """ a = get_module_path(module) - return a and opj(a, *args) or False + if zipfile.is_zipfile( a +'.zip') : + zip = zipfile.ZipFile( a + ".zip") + files = ['/'.join(f.split('/')[1:]) for f in zip.namelist()] + else: + files = tools.osutil.listdir(a, True) + for ar in args: + if ar not in files: + return False + res = a and opj(a, *args) or False + return res + def get_modules(): @@ -297,9 +307,10 @@ def load_information_from_description_file(module): """ :param module: The name of the module (sale, purchase, ...) """ + for filename in ['__openerp__.py', '__terp__.py']: description_file = get_module_resource(module, filename) - if os.path.isfile(description_file): + if description_file : return eval(tools.file_open(description_file).read()) #TODO: refactor the logger in this file to follow the logging guidelines @@ -332,9 +343,8 @@ def upgrade_graph(graph, cr, module_list, force=None): for module in module_list: mod_path = get_module_path(module) terp_file = get_module_resource(module, '__openerp__.py') - if not terp_file or not os.path.isfile(terp_file): + if not terp_file: terp_file = get_module_resource(module, '__terp__.py') - if not mod_path or not terp_file: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not found, skipped' % (module)) continue diff --git a/bin/addons/base/module/module.py b/bin/addons/base/module/module.py index b446f39f5b5..74cd018399c 100644 --- a/bin/addons/base/module/module.py +++ b/bin/addons/base/module/module.py @@ -247,7 +247,7 @@ class module(osv.osv): else: od = self.browse(cr, uid, ids2)[0] mdemo = od.demo or mdemo - + terp = self.get_module_info(module.name) try: self._check_external_dependencies(terp) From 3d6b88c87e888fd1219c75a0ead7397f1bf7bcd0 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Mon, 11 Oct 2010 12:27:03 +0530 Subject: [PATCH 2/3] [FIX] fixed regression on get_module_resource method to clean checking of file bzr revid: hmo@tinyerp.com-20101011065703-96zngxucees6zwx1 --- bin/addons/__init__.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index 7db007b732f..8e75a7d1124 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -270,16 +270,17 @@ def get_module_resource(module, *args): @return: absolute path to the resource """ a = get_module_path(module) + res = a and opj(a, *args) or False if zipfile.is_zipfile( a +'.zip') : zip = zipfile.ZipFile( a + ".zip") - files = ['/'.join(f.split('/')[1:]) for f in zip.namelist()] + files = [opj(a,'/'.join(f.split('/')[1:])) for f in zip.namelist()] + if res in files: + return res else: - files = tools.osutil.listdir(a, True) - for ar in args: - if ar not in files: - return False - res = a and opj(a, *args) or False - return res + if os.path.isfile(res): + return res + + return False From f9eb2e0260ba98475860e4daef7d12814fd40b5e Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 11 Oct 2010 12:24:39 +0200 Subject: [PATCH 3/3] [FIX] addons: fixed cross-platform compatibility for get_module_resource() bzr revid: odo@openerp.com-20101011102439-qgrsxquxdmasnty8 --- bin/addons/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index 8e75a7d1124..72e9fb2c6e2 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -273,13 +273,12 @@ def get_module_resource(module, *args): res = a and opj(a, *args) or False if zipfile.is_zipfile( a +'.zip') : zip = zipfile.ZipFile( a + ".zip") - files = [opj(a,'/'.join(f.split('/')[1:])) for f in zip.namelist()] + files = ['/'.join(f.split('/')[1:]) for f in zip.namelist()] + res = '/'.join(args) if res in files: - return res - else: - if os.path.isfile(res): - return res - + return opj(a, res) + elif os.path.isfile(res): + return res return False