From 175cd4cdd6d396ef5d14119e1186823ed5f93cde Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Thu, 3 May 2007 19:21:49 +0000 Subject: [PATCH] .ZIP Module support: improvement for supporting .zip extension wizard for importing .ZIP wizard for exportting .ZIP: bugfix and improve bzr revid: fp@tinyerp.com-a9ffc9ab126a9ae33dc02e212ed6762853d908ed --- bin/addons/__init__.py | 7 +- bin/addons/base/module/module_wizard.xml | 18 ++- bin/addons/base/module/wizard/__init__.py | 3 +- ...dule_wizard.py => wizard_module_export.py} | 2 +- .../module/wizard/wizard_module_import.py | 103 ++++++++++++++++++ bin/tools/misc.py | 7 +- 6 files changed, 127 insertions(+), 13 deletions(-) rename bin/addons/base/module/wizard/{move_module_wizard.py => wizard_module_export.py} (98%) create mode 100644 bin/addons/base/module/wizard/wizard_module_import.py diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index e25b5f081c5..3d1a77065e9 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -131,9 +131,11 @@ def create_graph(module_list, force=[]): packages = [] for module in module_list: + if module[-4:]=='.zip': + module = module[:-4] terp_file = opj(ad, module, '__terp__.py') mod_path = opj(ad, module) - if os.path.isfile(terp_file) or zipfile.is_zipfile(mod_path): + if os.path.isfile(terp_file) or zipfile.is_zipfile(mod_path+'.zip'): info = eval(tools.file_open(terp_file).read()) if info.get('installable', True): packages.append((module, info.get('depends', []), info)) @@ -191,6 +193,7 @@ def load_module_graph(cr, graph, status={}): for filename in package.datas.get('%s_xml' % kind, []): mode = 'update' if hasattr(package, 'init') or package_state=='to install': + print 'Mode', mode, filename mode = 'init' logger.notifyChannel('init', netsvc.LOG_INFO, 'addon:%s:loading %s' % (m, filename)) name, ext = os.path.splitext(filename) @@ -235,7 +238,7 @@ def register_classes(): imp.load_module(m, *imp.find_module(m)) except ImportError: import zipimport - mod_path = opj(ad, m) + mod_path = opj(ad, m+'.zip') zimp = zipimport.zipimporter(mod_path) zimp.load_module(m) diff --git a/bin/addons/base/module/module_wizard.xml b/bin/addons/base/module/module_wizard.xml index df0ebc2c2bd..967d9c990a9 100644 --- a/bin/addons/base/module/module_wizard.xml +++ b/bin/addons/base/module/module_wizard.xml @@ -9,15 +9,21 @@ name="module.info_get"/> --> + name="base.module.export" + id="wizard_base_module_export"/> + + + id="menu_wizard_module_import"/> Download module list diff --git a/bin/addons/base/module/wizard/__init__.py b/bin/addons/base/module/wizard/__init__.py index ecf160f51f7..4e36b2d57d3 100644 --- a/bin/addons/base/module/wizard/__init__.py +++ b/bin/addons/base/module/wizard/__init__.py @@ -33,4 +33,5 @@ import wizard_module_lang_install import add_new import wizard_export_lang import wizard_import_lang -import move_module_wizard +import wizard_module_export +import wizard_module_import diff --git a/bin/addons/base/module/wizard/move_module_wizard.py b/bin/addons/base/module/wizard/wizard_module_export.py similarity index 98% rename from bin/addons/base/module/wizard/move_module_wizard.py rename to bin/addons/base/module/wizard/wizard_module_export.py index 446dafe5445..d93fb5082b5 100644 --- a/bin/addons/base/module/wizard/move_module_wizard.py +++ b/bin/addons/base/module/wizard/wizard_module_export.py @@ -95,4 +95,4 @@ class move_module_wizard(wizard.interface): } } } -move_module_wizard('tmp.wizard') +move_module_wizard('base.module.export') diff --git a/bin/addons/base/module/wizard/wizard_module_import.py b/bin/addons/base/module/wizard/wizard_module_import.py new file mode 100644 index 00000000000..0731de4030c --- /dev/null +++ b/bin/addons/base/module/wizard/wizard_module_import.py @@ -0,0 +1,103 @@ +############################################################################## +# +# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + + +import wizard +import osv +import pooler +import os +import tools + +import zipfile +import StringIO +import base64 + +finish_form =''' +
+