--- orig/MoinMoin/util/pysupport.py
+++ mod/MoinMoin/util/pysupport.py
@@ -41,35 +41,51 @@
         Return None on failure.
     """
     if path:
-        import imp
-        complete_modulename = modulename
+        #
+        # see Python-src/Demo/imputil/knee.py how import should be done
+        #
+        import imp, sys
+
         items = modulename.split('.')
-        modulename = items[-1]
-        del items[-1]
-        
-        try:
-            # get the real path of the package now:
-            real_path = path        
-            for package_name in items:
-                file = None
-                try:
-                    file, real_path, descriptor = imp.find_module(package_name, [real_path])
-                finally:
-                    if file: file.close()
-        
-            md_file = None
+        parent = None
+        real_path = [path]
+        fqname = None
+        for part_name in items:
+            # keep full qualified module name up to date
+            if fqname is None:
+                fqname = part_name
+            else:
+                fqname = fqname + '.' + part_name
+            ## this is the place to check sys.modules if the module
+            ## is already available
+            ## WARNING: this does not work with farm wikis, cause all
+            ## farm plugin paths would map to the same 'plugin' top
+            ## module!
+            ## We need a dummy module ('wiki_'+sha(path)) to keep them
+            ## apart (create with imp.new_module()?)
+            # find & import the module
+            try:
+                fp, pathname, stuff = imp.find_module(part_name, real_path or parent.__path__)
+            except ImportError:
+                # no need to close fp here, cause its only open if found
+                return None
             try:
-                md_file, md_fname, md_fd = imp.find_module(modulename, [real_path])
-                mod = imp.load_module(complete_modulename, md_file, md_fname, md_fd)
-                return mod.__dict__[name]
+                mod = imp.load_module(fqname, fp, pathname, stuff)
             finally:
-                if md_file:
-                    md_file.close()
-        except KeyError:
-            raise Exception('Something with your module directories is wrong (wrong __init__.py files?)')
-        except ImportError:
-            return None
+                if fp: fp.close()
+            # update parent module up to date
+            if parent is None:
+                # we only need real_path for the first import, after
+                # this parent.__path__ is enough
+                real_path = None
+            else:
+                setattr(parent, part_name, mod)
+            parent = mod
+        return getattr(mod, name, None)
     else:
+        # this part is for MoinMoin imports, we use __import__
+        # which will also use sys.modules as cache, but thats
+        # no harm cause MoinMoin is global anyway.
         try:
             module = __import__(modulename, globals(), {}, [name]) # {} was: locals()
         except ImportError:



