[Checkins] SVN: zope.introspectorui/trunk/src/zope/introspectorui/util.py Add helper module.

Uli Fouquet uli at gnufix.de
Sat Aug 9 12:49:03 EDT 2008


Log message for revision 89581:
  Add helper module.

Changed:
  A   zope.introspectorui/trunk/src/zope/introspectorui/util.py

-=-
Added: zope.introspectorui/trunk/src/zope/introspectorui/util.py
===================================================================
--- zope.introspectorui/trunk/src/zope/introspectorui/util.py	                        (rev 0)
+++ zope.introspectorui/trunk/src/zope/introspectorui/util.py	2008-08-09 16:49:01 UTC (rev 89581)
@@ -0,0 +1,33 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Helpers for the zope.introspectorui.
+"""
+from zope.traversing.browser.interfaces import IAbsoluteURL
+from zope.component import getMultiAdapter
+
+def code_breadcrumbs(url, dotted_name):
+    """Breadcrumbs for code objects.
+
+    The `url` parameter should be a link to the object denoted by the
+    dotted name `dotted_name``.
+    """
+    url_parts = url.split('/')
+    dotted_name_parts = dotted_name.split('.')
+    start_len = len(url_parts) - len(dotted_name_parts)
+    url_start = '/'.join(url_parts[:start_len])
+    result = []
+    for name in dotted_name_parts:
+        url_start = '/'.join([url_start, name])
+        result.append(dict(name=name, url=url_start))
+    return tuple(result)



More information about the Checkins mailing list