[Zope-Checkins] SVN: Zope/trunk/lib/python/App/Extensions.py ProductDispatcher's __bobo_traverse__ now checks all products registered in Control_Panel.Products rather than simply checking the python Products namespace package.

Rocky Burt rocky at serverzen.com
Tue May 2 16:57:54 EDT 2006


Log message for revision 67868:
  ProductDispatcher's __bobo_traverse__ now checks all products registered in Control_Panel.Products rather than simply checking the python Products namespace package.

Changed:
  U   Zope/trunk/lib/python/App/Extensions.py

-=-
Modified: Zope/trunk/lib/python/App/Extensions.py
===================================================================
--- Zope/trunk/lib/python/App/Extensions.py	2006-05-02 20:44:47 UTC (rev 67867)
+++ Zope/trunk/lib/python/App/Extensions.py	2006-05-02 20:57:53 UTC (rev 67868)
@@ -78,6 +78,7 @@
     if d: raise ValueError, (
         'The file name, %s, should be a simple file name' % name)
 
+    result = None
     if checkProduct:
         l = name.find('.')
         if l > 0:
@@ -85,15 +86,39 @@
             n = name[l + 1:]
             for product_dir in Products.__path__:
                 r = _getPath(product_dir, os.path.join(p, prefix), n, suffixes)
-                if r is not None: return r
+                if r is not None: result = r
 
-    import App.config
-    cfg = App.config.getConfiguration()
-    sw=os.path.dirname(os.path.dirname(cfg.softwarehome))
-    for home in (cfg.instancehome, sw):
-        r=_getPath(home, prefix, name, suffixes)
-        if r is not None: return r
+    if result is None:
+        import App.config
+        cfg = App.config.getConfiguration()
+        sw=os.path.dirname(os.path.dirname(cfg.softwarehome))
+        for home in (cfg.instancehome, sw):
+            r=_getPath(home, prefix, name, suffixes)
+            if r is not None: result = r
 
+    if result is None:
+        try:
+            l = name.find('.')
+            if l > 0:
+                realName = name[l + 1:]
+                toplevel = name[:l]
+                
+                m = __import__(toplevel)
+        
+                d = os.path.join(m.__path__[0], prefix, realName)
+                
+                for s in suffixes:
+                    if s: s="%s.%s" % (d, s)
+                    else: s=d
+                    if os.path.exists(s): 
+                        result = s
+                        break
+        except:
+            pass
+        
+
+    return result
+
 def getObject(module, name, reload=0,
               # The use of a mutable default is intentional here,
               # because modules is a module cache.



More information about the Zope-Checkins mailing list