[Zope3-checkins] CVS: zopeproducts/zwiki - traversal.py:1.1 TODO.txt:1.7 browser.py:1.7 configure.zcml:1.11 zwiki.py:1.11 traverser.py:NONE
Stephan Richter
srichter@cbu.edu
Wed, 9 Apr 2003 09:42:00 -0400
Update of /cvs-repository/zopeproducts/zwiki
In directory cvs.zope.org:/tmp/cvs-serv3233
Modified Files:
TODO.txt browser.py configure.zcml zwiki.py
Added Files:
traversal.py
Removed Files:
traverser.py
Log Message:
- Added FTP (File) Views for WikiPages.
- Added Traversable in addition Traverser.
- Wrote tests for Traversable and Traverser.
- Added renderer test directory.
- Moved from traverser.py to traversable.py to conform to convention.
=== Added File zopeproducts/zwiki/traversal.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: traversal.py,v 1.1 2003/04/09 13:41:29 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
from zope.app.interfaces.traversing import ITraversable
from zope.app.traversing.namespace import UnexpectedParameters
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,)
_marker = object()
class WikiPageTraversable:
"""Traverses wikipages via wiki itself and getattr.
"""
__implements__ = ITraversable
__used_for__ = IWikiPage
def __init__(self, page):
self._page = page
self._wiki = getParent(page)
def traverse(self, name, parameters, original_name, furtherPath):
if parameters:
raise UnexpectedParameters(parameters)
subobj = self._wiki.get(name, _marker)
if subobj is _marker:
subobj = getattr(self._page, name, _marker)
if subobj is _marker:
raise NotFoundError, original_name
return subobj
=== zopeproducts/zwiki/TODO.txt 1.6 => 1.7 ===
--- zopeproducts/zwiki/TODO.txt:1.6 Tue Apr 8 22:49:08 2003
+++ zopeproducts/zwiki/TODO.txt Wed Apr 9 09:41:29 2003
@@ -9,7 +9,6 @@
- Add tests for plain text and STX formatter.
- - Add tests for Traverser (I have no clue how to do that).
Rendering/Views
@@ -20,7 +19,9 @@
- Create custom HTMLDocument class for rendering the STX in Wiki style.
- - Make sure FTP and WebDAV work.
+ - Make sure WebDAV work.
+
+ - Add File Extension recognition.
- Have a "Jump to" form on the WikiPage view.
@@ -31,8 +32,6 @@
- Improve 'Add Comment' screen to show existing Wiki content.
- - Custom Widget for source types is not working. Needs to be fixed.
-
Other Features
@@ -53,6 +52,4 @@
- Implements E-mail subscriptions.
- - Use Renderer classes to implement comment generator.
-
- - Internationalize the product.
\ No newline at end of file
+ - Use Renderer classes to implement comment generator.
\ No newline at end of file
=== zopeproducts/zwiki/browser.py 1.6 => 1.7 ===
--- zopeproducts/zwiki/browser.py:1.6 Tue Apr 8 22:49:08 2003
+++ zopeproducts/zwiki/browser.py Wed Apr 9 09:41:29 2003
@@ -20,7 +20,7 @@
from zope.app.interfaces.dublincore import ICMFDublinCore
-from zope.component import getAdapter, getView, getService
+from zope.component import getAdapter, getView, getService, createObject
from zope.app.browser.container.adding import Adding
from zope.app.browser.form.widget import ListWidget
from zope.app.form.widget import CustomWidget
@@ -85,7 +85,7 @@
count += 1
return rendered_items
-
+
class EditWikiPage(object):
=== zopeproducts/zwiki/configure.zcml 1.10 => 1.11 ===
--- zopeproducts/zwiki/configure.zcml:1.10 Wed Apr 9 00:52:27 2003
+++ zopeproducts/zwiki/configure.zcml Wed Apr 9 09:41:29 2003
@@ -96,6 +96,8 @@
file="wiki_icon.gif"
/>
+ <!-- WikiPage browser configuration -->
+
<browser:addform
label="Add Wiki Page"
name="AddWikiPage"
@@ -103,7 +105,7 @@
content_factory=".zwiki.WikiPage"
permission="zope.ManageContent"
fields="source type"
- class=".browser.EditWikiPage."
+ class=".browser.EditWikiPage"
menu="add_wiki"
title="Wiki Page"/>
@@ -114,7 +116,7 @@
name="edit.html"
permission="zope.ManageContent"
fields="source type"
- class=".browser.EditWikiPage."
+ class=".browser.EditWikiPage"
menu="zmi_views" title="Edit" />
<browser:page
@@ -157,10 +159,29 @@
<browser:page
name="_traverse"
for=".interfaces.IWikiPage"
- class=".traverser.WikiPageTraverser"
- permission="zope.Public"
- />
+ class=".traversal.WikiPageTraverser"
+ permission="zope.Public" />
+<adapter
+ factory=".traversal.WikiPageTraversable"
+ provides="zope.app.interfaces.traversing.ITraversable"
+ for=".interfaces.IWikiPage" />
+
+
+<!-- WikiPage FTP configurations -->
+<adapter
+ for=".interfaces.IWikiPage"
+ provides="zope.app.interfaces.file.IReadFile"
+ factory=".zwiki.WikiPageReadFile"
+ permission="zope.View"
+ />
+
+<adapter
+ for=".interfaces.IWikiPage"
+ provides="zope.app.interfaces.file.IWriteFile"
+ factory=".zwiki.WikiPageWriteFile"
+ permission="zope.ManageContent"
+ />
<!-- Wiki-specifc configuration -->
=== zopeproducts/zwiki/zwiki.py 1.10 => 1.11 ===
--- zopeproducts/zwiki/zwiki.py:1.10 Tue Apr 8 22:49:08 2003
+++ zopeproducts/zwiki/zwiki.py Wed Apr 9 09:41:29 2003
@@ -18,6 +18,7 @@
from persistence import Persistent
from zope.component import getAdapter, getService
+from zope.component.interfaces import IFactory
from zope.proxy.context import ContextWrapper
from zope.app.content.folder import Folder
from zope.app.traversing import getParent, objectName
@@ -35,6 +36,23 @@
__implements__ = (IWiki, Folder.__implements__)
+class WikiFactory:
+ __implements__ = IFactory
+
+ def __call__(self):
+ wiki = Wiki()
+ page = WikiPage()
+ page.type = u'Structured Text'
+ page.source = u'This is the FrontPage of the Wiki.'
+ wiki.setObject('FrontPage', page)
+ return wiki
+
+ def getInterfaces(self):
+ return Wiki.__implements__
+
+WikiFactory = WikiFactory()
+
+
class WikiPage(Persistent):
__doc__ = IWikiPage.__doc__
@@ -117,4 +135,26 @@
subs = ()
children.append((wrapped, subs))
return children
+
+
+# Adapters for file-system style access
+
+class WikiPageReadFile:
+
+ def __init__(self, context):
+ self.context = context
+
+ def read(self):
+ return self.context.source
+
+ def size(self):
+ return len(self.context.source)
+
+class WikiPageWriteFile:
+
+ def __init__(self, context):
+ self.context = context
+
+ def write(self, data):
+ self.context.source = unicode(data)
=== Removed File zopeproducts/zwiki/traverser.py ===