diff --git a/CHANGELOG b/CHANGELOG index b25add96c6..7dfd90bec0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Remove support of zipped modules + Version 2.0.0 - 2011-04-26 * Bug fixes (see mercurial logs for details) * Use md5 hash for indexing translation diff --git a/trytond/modules/__init__.py b/trytond/modules/__init__.py index dfd41fcd38..3728c2b9e0 100644 --- a/trytond/modules/__init__.py +++ b/trytond/modules/__init__.py @@ -3,8 +3,6 @@ from __future__ import with_statement import os, sys, imp import itertools -import zipfile -import zipimport import traceback import logging import contextlib @@ -152,7 +150,7 @@ def create_graph(module_list, force=None): # directory tryton_file = OPJ(ep.dist.location, '__tryton__.py') mod_path = os.path.dirname(ep.dist.location) - if os.path.isfile(tryton_file) or zipfile.is_zipfile(mod_path+'.zip'): + if os.path.isfile(tryton_file): with tools.file_open(tryton_file, subdir='') as fp: info = tools.safe_eval(fp.read()) packages.append((module, info.get('depends', []), info)) @@ -359,11 +357,7 @@ def register_classes(reload_p=False): reload(sys.modules['trytond.modules.' + module]) continue - if os.path.isfile(OPJ(MODULES_PATH, module + '.zip')): - mod_path = OPJ(MODULES_PATH, module + '.zip') - zimp = zipimport.zipimporter(mod_path) - zimp.load_module('trytond.modules.' + module) - elif os.path.isdir(OPJ(MODULES_PATH, module)): + if os.path.isdir(OPJ(MODULES_PATH, module)): mod_file, pathname, description = imp.find_module(module, [MODULES_PATH]) try: diff --git a/trytond/tests/test_tryton.py b/trytond/tests/test_tryton.py index 73cf654b30..9ecd460d3f 100644 --- a/trytond/tests/test_tryton.py +++ b/trytond/tests/test_tryton.py @@ -23,7 +23,6 @@ import doctest from lxml import etree import time import imp -import zipimport _MODULES = False if __name__ == '__main__': @@ -210,14 +209,7 @@ def modules_suite(): for package in graph: module = package.name test_module = 'trytond.modules.%s.tests' % module - if os.path.isfile(os.path.join(MODULES_PATH, module + '.zip')): - mod_path = os.path.join(MODULES_PATH, module + '.zip') - zimp = zipimport.zipimporter(mod_path) - try: - test_mod = zimp.load_module(test_module) - except zipimport.ZipImportError: - continue - elif os.path.isdir(os.path.join(MODULES_PATH, module)) or \ + if os.path.isdir(os.path.join(MODULES_PATH, module)) or \ module in EGG_MODULES: try: test_mod = __import__(test_module, fromlist=['']) diff --git a/trytond/tools/misc.py b/trytond/tools/misc.py index 0639eab3ed..fc41cbdcf7 100644 --- a/trytond/tools/misc.py +++ b/trytond/tools/misc.py @@ -6,7 +6,6 @@ Miscelleanous tools used by tryton """ import os, sys import subprocess -import zipfile from threading import local import smtplib try: @@ -78,27 +77,27 @@ def file_open(name, mode="r", subdir='modules'): from trytond.modules import EGG_MODULES root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - name3 = False + egg_name = False if subdir == 'modules': module_name = name.split(os.sep)[0] if module_name in EGG_MODULES: epoint = EGG_MODULES[module_name] mod_path = os.path.join(epoint.dist.location, *epoint.module_name.split('.')[:-1]) - name3 = os.path.join(mod_path, name) - if not os.path.isfile(name3): + egg_name = os.path.join(mod_path, name) + if not os.path.isfile(egg_name): # Find module in path for path in sys.path: mod_path = os.path.join(path, *epoint.module_name.split('.')[:-1]) - name3 = os.path.join(mod_path, name) - if os.path.isfile(name3): + egg_name = os.path.join(mod_path, name) + if os.path.isfile(egg_name): break - if not os.path.isfile(name3): + if not os.path.isfile(egg_name): # When testing modules from setuptools location is the # module directory - name3 = os.path.join(os.path.dirname(epoint.dist.location), - name) + egg_name = os.path.join( + os.path.dirname(epoint.dist.location), name) if subdir: if subdir == 'modules'\ @@ -113,33 +112,11 @@ def file_open(name, mode="r", subdir='modules'): else: name = os.path.join(root_path, name) - # Check for a zipfile in the path - head = name - zipname = False - name2 = False - while True: - head, tail = os.path.split(head) - if head == root_path: - break - if not tail: - break - if zipname: - zipname = os.path.join(tail, zipname) - else: - zipname = tail - if zipfile.is_zipfile(head+'.zip'): - zfile = zipfile.ZipFile(head+'.zip') - try: - return StringIO.StringIO(zfile.read(os.path.join( - os.path.basename(head), zipname).replace( - os.sep, '/'))) - except Exception: - name2 = os.path.normpath(os.path.join(head + '.zip', zipname)) - for i in (name2, name, name3): + for i in (name, egg_name): if i and os.path.isfile(i): return open(i, mode) - raise IOError, 'File not found : '+str(name) + raise IOError('File not found : %s ' % name) def get_smtp_server(): """