[Checkins] SVN: z3c.jbot/trunk/z3c/jbot/manager.py Check the Zope2 magic Products semi-namespace as well.

Wichert Akkerman wichert at wiggy.net
Thu Jul 17 10:08:41 EDT 2008


Log message for revision 88442:
  Check the Zope2 magic Products semi-namespace as well.

Changed:
  U   z3c.jbot/trunk/z3c/jbot/manager.py

-=-
Modified: z3c.jbot/trunk/z3c/jbot/manager.py
===================================================================
--- z3c.jbot/trunk/z3c/jbot/manager.py	2008-07-17 13:36:22 UTC (rev 88441)
+++ z3c.jbot/trunk/z3c/jbot/manager.py	2008-07-17 14:08:40 UTC (rev 88442)
@@ -14,6 +14,22 @@
     else:
         return 0
 
+def find_zope2_product(path):
+    """Check the Zope2 magic Products semi-namespace to see if the
+    path is part of a Product."""
+    _syspaths = sorted(
+                sys.modules["Products"].__path__,
+                key=lambda syspath: root_length(syspath, path), reverse=True)
+    syspath = _syspaths[0]
+
+    if not path.startswith(syspath):
+        return None
+
+    product = path[len(syspath)+1:].split(os.path.sep, 2)[0]
+
+    return "Products." + product
+
+
 def find_package(syspaths, path):
     """Determine the Python-package where path is located.  If the path is
     not located within the Python sys-path, return ``None``."""
@@ -25,6 +41,8 @@
     
     path = os.path.normpath(path)
     if not path.startswith(syspath):
+        if utility.ZOPE_2:
+            return find_zope2_product(path)
         return None
     
     path = path[len(syspath):]



More information about the Checkins mailing list