Commit 0b87d146 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Cache downloaded data in zc/buildout/buildout.py:_open() in memory to accelerate remote extends.

parent 931a4b73
1.7.1-dev-SlapOS-005
--------------------
- Cache downloaded data in zc/buildout/buildout.py:_open() in memory to accelerate remote extends.
1.7.1-dev-SlapOS-004 1.7.1-dev-SlapOS-004
-------------------- --------------------
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# #
############################################################################## ##############################################################################
name = "zc.buildout" name = "zc.buildout"
version = "1.7.1-dev-SlapOS-004" version = "1.7.1-dev-SlapOS-005"
import os import os
from setuptools import setup from setuptools import setup
......
...@@ -22,6 +22,7 @@ except ImportError: ...@@ -22,6 +22,7 @@ except ImportError:
from md5 import md5 from md5 import md5
import ConfigParser import ConfigParser
from cStringIO import StringIO
import copy import copy
import distutils.errors import distutils.errors
import glob import glob
...@@ -1691,6 +1692,7 @@ def _save_options(section, options, f): ...@@ -1691,6 +1692,7 @@ def _save_options(section, options, f):
for option in sorted(options.keys()): for option in sorted(options.keys()):
_save_option(option, options.get(option), f) _save_option(option, options.get(option), f)
_open_download_cache = {}
_open_parser_cache = {} _open_parser_cache = {}
def _open(base, filename, seen, dl_options, override, downloaded): def _open(base, filename, seen, dl_options, override, downloaded):
"""Open a configuration file and return the result as a dictionary, """Open a configuration file and return the result as a dictionary,
...@@ -1722,8 +1724,14 @@ def _open(base, filename, seen, dl_options, override, downloaded): ...@@ -1722,8 +1724,14 @@ def _open(base, filename, seen, dl_options, override, downloaded):
base = os.path.dirname(filename) base = os.path.dirname(filename)
else: else:
filename = base + '/' + filename filename = base + '/' + filename
path, is_temp = download(filename) data = _open_download_cache.get(filename)
fp = open(path) if data is None:
path, is_temp = download(filename)
data = file(path).read()
_open_download_cache[filename] = data
else:
is_temp = False
fp = StringIO(data)
base = filename[:filename.rfind('/')] base = filename[:filename.rfind('/')]
else: else:
filename = os.path.join(base, filename) filename = os.path.join(base, filename)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment