[Zope3-checkins] CVS: zopeproducts/zwiki - browser.py:1.2 configure.zcml:1.4 zwiki.py:1.4

Stephan Richter srichter@cbu.edu
Sun, 6 Apr 2003 17:45:50 -0400


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

Modified Files:
	browser.py configure.zcml zwiki.py 
Log Message:
Good point to check in. Assigning parents works now. I also fixed the 
failing test.


=== zopeproducts/zwiki/browser.py 1.1 => 1.2 ===
--- zopeproducts/zwiki/browser.py:1.1	Sat Apr  5 15:50:02 2003
+++ zopeproducts/zwiki/browser.py	Sun Apr  6 17:45:50 2003
@@ -18,9 +18,12 @@
 import re
 from urllib import quote, unquote
 
+from zope.component import getAdapter
 from zope.app.browser.container.adding import Adding
 from zope.app.traversing import getParent, getPath, objectName
 
+from zopeproducts.zwiki.interfaces import IWikiPageHierarchy
+
 
 urlchars = r'[A-Za-z0-9/:@_%~#=&\.\-\?\+\$,]+'
 urlendchar  = r'[A-Za-z0-9/]'
@@ -177,3 +180,20 @@
     
         # otherwise, leave alone
         return match.group(0)
+
+
+class EditWikiParents:
+
+    def parents(self):
+        hier = getAdapter(self.context, IWikiPageHierarchy)
+        return hier.parents
+
+    def availableWikis(self):
+        wiki = getParent(self.context)
+        return wiki.keys()
+        
+    def setParents(self, parents):
+        hier = getAdapter(self.context, IWikiPageHierarchy)
+        hier.reparent(parents)
+        return self.request.response.redirect('./@@parents.html')
+        


=== zopeproducts/zwiki/configure.zcml 1.3 => 1.4 ===
--- zopeproducts/zwiki/configure.zcml:1.3	Sat Apr  5 20:01:03 2003
+++ zopeproducts/zwiki/configure.zcml	Sun Apr  6 17:45:50 2003
@@ -123,6 +123,16 @@
       menu="zmi_views"
       title="View"/>
 
+
+  <browser:pages
+      for=".interfaces.IWikiPage"
+      class=".browser.EditWikiParents"
+      permission="zope.ManageContent">
+      <browser:page name="parents.html" template="parents_page.pt" 
+          menu="zmi_views" title="Parents" />
+      <browser:page name="setParents.html" attribute="setParents" />
+  </browser:pages>
+
   <browser:defaultView
       name="view.html"
       for=".interfaces.IWikiPage"/>


=== zopeproducts/zwiki/zwiki.py 1.3 => 1.4 ===
--- zopeproducts/zwiki/zwiki.py:1.3	Sat Apr  5 20:01:03 2003
+++ zopeproducts/zwiki/zwiki.py	Sun Apr  6 17:45:50 2003
@@ -21,6 +21,8 @@
 
 from zopeproducts.zwiki.interfaces import IWiki, IWikiPage, IWikiPageHierarchy
 
+__metaclass__ = type
+
 HierarchyKey = 'http://www.zope.org/zwiki#1.0/PageHierarchy/parents'
 
 class Wiki(Folder):
@@ -57,20 +59,20 @@
 
     def __init__(self, context):
         self.context = context
-        self.annotations = getAdapter(context, IAnnotations)
-        data = self.annotations.get(HierarchyKey)
-        if data is None:
-            self.annotations[HierarchyKey] = ()
+        self._annotations = getAdapter(context, IAnnotations)
+        if not self._annotations.get(HierarchyKey):
+            self._annotations[HierarchyKey] = ()
 
     def reparent(self, parents):
         "See zopeproducts.zwiki.interfaces.IWikiPageHierarchy"
-        self.parents = parents
+        self.setParents(parents)
 
     def setParents(self, parents):
-        self.annotations[HierarchyKey] = tuple(parents)
+        data = self._annotations.get(HierarchyKey)
+        self._annotations[HierarchyKey] = tuple(parents)
         
     def getParents(self):
-        return self.annotations[HierarchyKey]
+        return self._annotations[HierarchyKey]
 
     parents = property(getParents, setParents)