From 795e755b42a8786e5bbe5f318b05d9943cd98a4c Mon Sep 17 00:00:00 2001 From: jas Date: Fri, 8 Oct 2010 18:50:28 +0530 Subject: [PATCH] [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)