Commit 5b5df532 authored by Jim Fulton's avatar Jim Fulton

Added module cache to prevent multiply importing storage modules.

parent 5fc2331f
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
"""Start the server storage. """Start the server storage.
""" """
__version__ = "$Revision: 1.8 $"[11:-2] __version__ = "$Revision: 1.9 $"[11:-2]
import sys, os, getopt, string import sys, os, getopt, string
...@@ -99,14 +99,17 @@ def directory(p, n=1): ...@@ -99,14 +99,17 @@ def directory(p, n=1):
return d return d
def get_storage(m, n): def get_storage(m, n, cache={}):
p=sys.path p=sys.path
d, m = os.path.split(m) d, m = os.path.split(m)
if d: p=[d]+p
import imp
if m[-3:]=='.py': m=m[:-3] if m[-3:]=='.py': m=m[:-3]
im=imp.find_module(m,p) im=cache.get((d,m), 0)
im=imp.load_module(m, im[0], im[1], im[2]) if im==0:
if d: p=[d]+p
import imp
im=imp.find_module(m,p)
im=imp.load_module(m, im[0], im[1], im[2])
cache[(d,m)]=im
return getattr(im, n) return getattr(im, n)
......
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