[Zope3-checkins] CVS: zopeproducts/zwiki - traverser.py:1.1 TODO.txt:1.5 configure.zcml:1.8 zwiki.py:1.9

Stephan Richter srichter@cbu.edu
Tue, 8 Apr 2003 01:21:15 -0400


Update of /cvs-repository/zopeproducts/zwiki
In directory cvs.zope.org:/tmp/cvs-serv14783

Modified Files:
	TODO.txt configure.zcml zwiki.py 
Added Files:
	traverser.py 
Log Message:
Added beginnings of a traverser, so that we can have urls like 
wiki/wikipage1/wikipage2 (given that wikipage1 is a parent of wikipage2.


=== Added File zopeproducts/zwiki/traverser.py ===
##############################################################################
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
##############################################################################
"""Specific HTTP

$Id: traverser.py,v 1.1 2003/04/08 05:21:15 srichter Exp $
"""
from zope.component import getDefaultViewName, queryView
from zope.publisher.interfaces import IPublishTraverse
from zopeproducts.zwiki.interfaces import IWikiPage

from zope.exceptions import NotFoundError
from zope.app.traversing import getParent

from zope.proxy.introspection import removeAllProxies
from zope.proxy.context import ContextWrapper

class WikiPageTraverser:

    __implements__ = IPublishTraverse
    __used_for__ = IWikiPage

    def __init__(self, page, request):
        self.context = page
        self.wiki = getParent(page)
        self.request = request

    def publishTraverse(self, request, name):
        subob = self.wiki.get(name, None)

        # XXX: Check that subobj has self.context as parent!
        if subob is None:

            view = queryView(self.context, name, request)
            if view is not None:
                return view

            raise NotFoundError(self.context, name, request)

        subob = removeAllProxies(subob)
        return ContextWrapper(subob, self.wiki, name=name)

    def browserDefault(self, request):
        c = self.context
        view_name = getDefaultViewName(c, request)
        view_uri = "@@%s" % view_name
        return c, (view_uri,)



=== zopeproducts/zwiki/TODO.txt 1.4 => 1.5 ===
--- zopeproducts/zwiki/TODO.txt:1.4	Tue Apr  8 00:17:26 2003
+++ zopeproducts/zwiki/TODO.txt	Tue Apr  8 01:21:15 2003
@@ -10,7 +10,8 @@
     - Add tests for metaconfigure.py
 
     - Add tests for plain text and STX formatter.
-    
+
+    - Add tests for Traverser (I have no clue how to do that).    
 
   Rendering/Views
 
@@ -38,8 +39,10 @@
     - When creating a Wiki, the FrontPage WikiPage should be created by
       default.
 
-    - Implement a custom traverser for WikiPages, so that URLs can represent
-      the page hierarchy.
+    - Make use of Traverser features; i.e. create links that include
+      parents...
+
+    - Check in Traverser that found subobj has self.context as parent.
 
     - Implement search.
 


=== zopeproducts/zwiki/configure.zcml 1.7 => 1.8 ===
--- zopeproducts/zwiki/configure.zcml:1.7	Tue Apr  8 00:15:02 2003
+++ zopeproducts/zwiki/configure.zcml	Tue Apr  8 01:21:15 2003
@@ -153,6 +153,15 @@
       file="wikipage_icon.gif"
       />
 
+<browser:page
+    name="_traverse" 
+    for=".interfaces.IWikiPage"
+    class=".traverser.WikiPageTraverser" 
+    permission="zope.Public"
+    />
+
+
+
 <!-- Wiki-specifc configuration -->
 
 <serviceType 


=== zopeproducts/zwiki/zwiki.py 1.8 => 1.9 ===
--- zopeproducts/zwiki/zwiki.py:1.8	Tue Apr  8 00:15:02 2003
+++ zopeproducts/zwiki/zwiki.py	Tue Apr  8 01:21:15 2003
@@ -91,6 +91,7 @@
             return [self.context]
         wiki = getParent(self.context)
         name = self.getParents()[0]
+        print wiki
         wrapped = ContextWrapper(wiki[name], wiki, name=name)
         hier = getAdapter(wrapped, IWikiPageHierarchy)
         return hier.path() + [self.context]