SVN: r25432 - trunk/quixote

David Binger <dbinger-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Tue, 26 Oct 2004 10:12:47 -0400
Newsgroups gmane.comp.web.quixote.cvs
Message-ID <[email protected]>
Author: dbinger
Date: 2004-10-26 09:26:36 -0400 (Tue, 26 Oct 2004)
New Revision: 25432

Modified:
   trunk/quixote/util.py
Log:
Add get_directory_path() for obtaining the list of _q_traversed() Directories.


Modified: trunk/quixote/util.py
===================================================================
--- trunk/quixote/util.py	2004-10-25 22:45:00 UTC (rev 25431)
+++ trunk/quixote/util.py	2004-10-26 13:26:36 UTC (rev 25432)
@@ -350,3 +350,17 @@
         r += row_fmt % (k, v)
     r += htmltext('</table>')
     return r.getvalue()
+
+def get_directory_path():
+    """() -> [Directory]
+    Return the list of traversed Directory instances.
+    """
+    path = []
+    frame = sys._getframe()
+    while frame:
+        if frame.f_code.co_name == '_q_traverse':
+            self = frame.f_locals.get('self', None)
+            if path[:1] != [self] and isinstance(self, Directory):
+                path.insert(0, self)
+        frame = frame.f_back
+    return path