[Checkins] SVN: Grokstar/trunk/src/grokstar/ Move traverser out of the calendar; we also want to traverse to blog entries

Martijn Faassen faassen at infrae.com
Thu Feb 1 16:15:24 EST 2007


Log message for revision 72308:
  Move traverser out of the calendar; we also want to traverse to blog entries
  directly under the blog object. This is in preparation for making the
  'entries' folder our version storage.
  

Changed:
  U   Grokstar/trunk/src/grokstar/calendar.py
  A   Grokstar/trunk/src/grokstar/traverse.py

-=-
Modified: Grokstar/trunk/src/grokstar/calendar.py
===================================================================
--- Grokstar/trunk/src/grokstar/calendar.py	2007-02-01 20:44:33 UTC (rev 72307)
+++ Grokstar/trunk/src/grokstar/calendar.py	2007-02-01 21:15:24 UTC (rev 72308)
@@ -4,18 +4,7 @@
 import grok
 from hurry.query.query import Query
 from hurry import query
-from blog import Blog
 
-class BlogYearTraverser(grok.Traverser):
-    grok.context(Blog)
-
-    def traverse(self, name):
-        try:
-            year = int(name)
-        except ValueError:
-            return None
-        return Year(year)
-
 class Year(grok.Model):
     def __init__(self, year):
         self.year = year

Added: Grokstar/trunk/src/grokstar/traverse.py
===================================================================
--- Grokstar/trunk/src/grokstar/traverse.py	2007-02-01 20:44:33 UTC (rev 72307)
+++ Grokstar/trunk/src/grokstar/traverse.py	2007-02-01 21:15:24 UTC (rev 72308)
@@ -0,0 +1,16 @@
+import grok
+from grokstar.blog import Blog
+from grokstar.calendar import Year
+
+class BlogTraverser(grok.Traverser):
+    grok.context(Blog)
+
+    def traverse(self, name):
+        try:
+            year = int(name)
+        except ValueError:
+            return self.entry_traverse(name)
+        return Year(year)
+
+    def entry_traverse(self, name):
+        return self.context['entries'].get(name, None)



More information about the Checkins mailing list