[Zope3-checkins] CVS: zopeproducts/zwiki - TODO.txt:1.15 interfaces.py:1.8 meta.zcml:1.2 metaconfigure.py:1.2 sourcetype.py:1.2 wikipage.py:1.4
Stephan Richter
srichter@cbu.edu
Sat, 12 Apr 2003 19:06:04 -0400
Update of /cvs-repository/zopeproducts/zwiki
In directory cvs.zope.org:/tmp/cvs-serv13171
Modified Files:
TODO.txt interfaces.py meta.zcml metaconfigure.py
sourcetype.py wikipage.py
Log Message:
- Finished a bunch of promised tests. Except for Views everything is tested
now.
- Reworked the source type registry a bit to be more flexible. Now the
actual implementation of a source type interface is also registered. I
moved the createComment() method into the source class, since this is
where it belongs. We only want one createComment() method for each source
and not for each renderer.
=== zopeproducts/zwiki/TODO.txt 1.14 => 1.15 ===
--- zopeproducts/zwiki/TODO.txt:1.14 Thu Apr 10 21:37:45 2003
+++ zopeproducts/zwiki/TODO.txt Sat Apr 12 19:05:34 2003
@@ -3,21 +3,7 @@
Tests
- - Add tests for the rendering.
-
- - Add test for findChildren.
-
- - Add tests for plain text, STX, and ReST formatter.
-
- - Add tests for WikiMailer
-
- - Add tests for MailSubscriptions
-
- - Add tests for WikiPageReadFile, WikiPageWriteFile, SearchableText
-
- Write tests for diff module
-
- - Add a simple test for 'Wiki Text Index'.
Rendering/Views
=== zopeproducts/zwiki/interfaces.py 1.7 => 1.8 ===
--- zopeproducts/zwiki/interfaces.py:1.7 Thu Apr 10 21:37:45 2003
+++ zopeproducts/zwiki/interfaces.py Sat Apr 12 19:05:34 2003
@@ -79,6 +79,27 @@
names of the parent wiki pages.
"""
+ def path():
+ """Return the object path of the virtual Wiki Hierarchy.
+
+ The return value for this method should be a list of wiki objects
+ describing the path.
+
+ XXX: Wiki Pages can have several parents, so that we should be able to
+ have multiple paths; but let's not worry about that right now. At some
+ point this needs to be done though.
+ """
+
+ def findChildren(recursive=True):
+ """Returns a list of children for this wiki page.
+
+ If the recursive is True, the method recurses into all children
+ returning the entire sub-tree of this Wiki Page. Is the recursive
+ argument set to False, only the first level of children will be
+ returned.
+ """
+
+
class IMailSubscriptions(Interface):
"""This interface allows you to retrieve a list of E-mails for
mailings. In our context """
@@ -121,18 +142,48 @@
is used to recognize the type."""
-class IPlainTextSource(Interface):
+class ISource(Interface):
+ """Simple base interface for all possible Wiki Page Source types."""
+
+ def createComment(comment, number):
+ """Create a comment from the comment content and the number of the
+ comment.
+
+ Various source types want to create comments in various different
+ ways. This method allows us to specify a way to create comments for
+ every different source type.
+ """
+
+class IPlainTextSource(ISource):
"""Marker interface for a plain text source. Note that an implementation
of this interface should always derive from unicode or behave like a
unicode class."""
-class IStructuredTextSource(Interface):
+
+class IStructuredTextSource(ISource):
"""Marker interface for a structured text source. Note that an
implementation of this interface should always derive from unicode or
behave like a unicode class."""
-class IReStructuredTextSource(Interface):
+
+class IReStructuredTextSource(ISource):
"""Marker interface for a restructured text source. Note that an
implementation of this interface should always derive from unicode or
behave like a unicode class."""
+
+class ISourceRenderer(Interface):
+ """Objecrt implementing this interface are responsible for rendering an
+ ISource objects to an output format. This is the base class for all
+ possible output types."""
+
+ def render(context):
+ """Renders the source into another format.
+
+ The context argument is passed, since some rendering might require
+ some knowledge about the environment. If this turns out to be
+ unnecessary, we can remove this attribute later."""
+
+
+class IHTMLRenderer(ISourceRenderer):
+ """Renders an ISource object to HTML."""
=== zopeproducts/zwiki/meta.zcml 1.1 => 1.2 ===
--- zopeproducts/zwiki/meta.zcml:1.1 Tue Apr 8 00:14:21 2003
+++ zopeproducts/zwiki/meta.zcml Sat Apr 12 19:05:34 2003
@@ -10,13 +10,20 @@
available source types.
</description>
- <attribute name="for" required="yes">
+ <attribute name="interface" required="yes">
<description>
- The for attribute specifies a marker interface for specifying the
+ The for attribute specifies a interface for specifying the
particular source type.
</description>
</attribute>
+ <attribute name="class" required="yes">
+ <description>
+ The for attribute specifies the class that is implementing this
+ source type.
+ </description>
+ </attribute>
+
<attribute name="title" required="yes">
<description>
Provides a title for the source type.
@@ -38,7 +45,8 @@
<attribute name="factory" required="yes">
<description>
- Specifies the factory that is used to create the view on the source.
+ Specifies the factory that is used to create the view on the
+ source.
</description>
</attribute>
=== zopeproducts/zwiki/metaconfigure.py 1.1 => 1.2 ===
--- zopeproducts/zwiki/metaconfigure.py:1.1 Tue Apr 8 00:14:21 2003
+++ zopeproducts/zwiki/metaconfigure.py Sat Apr 12 19:05:34 2003
@@ -30,8 +30,9 @@
__class_implements__ = INonEmptyDirective
__implements__ = ISubdirectiveHandler
- def __init__(self, _context, interface, title=u''):
+ def __init__(self, _context, interface, class_, title=u''):
self.iface = _context.resolve(interface)
+ self.klass = _context.resolve(class_)
self.title = title
self.renderers = []
@@ -59,7 +60,7 @@
actions.append(Action(
discriminator = ('zwiki source type', self.title, self.iface),
callable=SourceTypes.provide,
- args = (self.title, self.iface)
+ args = (self.title, self.iface, self.klass)
)
)
=== zopeproducts/zwiki/sourcetype.py 1.1 => 1.2 ===
--- zopeproducts/zwiki/sourcetype.py:1.1 Tue Apr 8 00:13:19 2003
+++ zopeproducts/zwiki/sourcetype.py Sat Apr 12 19:05:34 2003
@@ -27,17 +27,20 @@
def __init__(self):
self.__types = {}
- def provide(self, title, iface):
+ def provide(self, title, iface, klass):
"See zopeproducts.zwiki.interfaces.IGlobalWikiSourceTypeService"
- self.__types[title] = iface
+ self.__types[title] = (iface, klass)
def get(self, title, default=None):
"See zopeproducts.zwiki.interfaces.IWikiSourceTypeService"
- return self.__types.get(title, default)
+ res = self.__types.get(title, default)
+ if res is not default:
+ res = res[0]
+ return res
def query(self, title):
"See zopeproducts.zwiki.interfaces.IWikiSourceTypeService"
- return self.__types[title]
+ return self.__types[title][0]
def getAllTitles(self):
"See zopeproducts.zwiki.interfaces.IWikiSourceTypeService"
@@ -45,12 +48,8 @@
def createObject(self, title, source):
"See zopeproducts.zwiki.interfaces.IWikiSourceTypeService"
- iface = self.query(title)
-
- class Source(unicode):
- __implements__ = iface
-
- return Source(source)
+ klass = self.__types[title][1]
+ return klass(source)
SourceTypes = GlobalWikiSourceTypeService()
=== zopeproducts/zwiki/wikipage.py 1.3 => 1.4 ===
--- zopeproducts/zwiki/wikipage.py:1.3 Thu Apr 10 21:37:45 2003
+++ zopeproducts/zwiki/wikipage.py Sat Apr 12 19:05:34 2003
@@ -99,7 +99,6 @@
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]
@@ -119,7 +118,7 @@
else:
subs = ()
children.append((wrapped, subs))
- return children
+ return tuple(children)
# Adapters for file-system style access
@@ -195,6 +194,7 @@
"See zopeproducts.zwiki.interfaces.IMailSubscriptions"
subscribers = list(self._annotations[SubscriberKey])
for email in emails:
+ # XXX: Make sure these are actually E-mail addresses.
if email not in subscribers:
subscribers.append(email.strip())
self._annotations[SubscriberKey] = tuple(subscribers)