[Zope-CVS] SVN: messageboard/trunk/ Added fully updated step 1 of the message board.

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri May 14 11:58:21 EDT 2004


Log message for revision 24659:
Added fully updated step 1 of the message board.



-=-
Added: messageboard/trunk/__init__.py
===================================================================
--- messageboard/trunk/__init__.py	2004-05-14 15:53:51 UTC (rev 24658)
+++ messageboard/trunk/__init__.py	2004-05-14 15:58:20 UTC (rev 24659)
@@ -0,0 +1 @@
+# Make it a Python package

Added: messageboard/trunk/browser/__init__.py
===================================================================
--- messageboard/trunk/browser/__init__.py	2004-05-14 15:53:51 UTC (rev 24658)
+++ messageboard/trunk/browser/__init__.py	2004-05-14 15:58:20 UTC (rev 24659)
@@ -0,0 +1 @@
+# Make it a Python package

Added: messageboard/trunk/browser/configure.zcml
===================================================================
--- messageboard/trunk/browser/configure.zcml	2004-05-14 15:53:51 UTC (rev 24658)
+++ messageboard/trunk/browser/configure.zcml	2004-05-14 15:58:20 UTC (rev 24659)
@@ -0,0 +1,71 @@
+<configure
+    xmlns="http://namespaces.zope.org/browser">
+
+  <addform
+      label="Add Message Board"
+      name="AddMessageBoard.html"
+      schema="book.messageboard.interfaces.IMessageBoard"
+      content_factory="book.messageboard.messageboard.MessageBoard"
+      fields="description"
+      permission="zope.ManageContent"
+      />
+
+  <addMenuItem
+      class="book.messageboard.messageboard.MessageBoard"
+      title="Message Board"
+      description="A Message Board"
+      permission="zope.ManageContent"
+      view="AddMessageBoard.html" 
+      />
+
+  <editform
+      schema="book.messageboard.interfaces.IMessageBoard"
+      for="book.messageboard.interfaces.IMessageBoard"
+      label="Change Message Board"
+      name="edit.html"
+      permission="zope.ManageContent"
+      menu="zmi_views" title="Edit" 
+      />
+
+  <containerViews
+      for="book.messageboard.interfaces.IMessageBoard"
+      index="zope.View"
+      contents="zope.View"
+      add="zope.ManageContent"
+      />
+
+  <addform
+      label="Add Message"
+      name="AddMessage.html"
+      schema="book.messageboard.interfaces.IMessage"
+      content_factory="book.messageboard.message.Message"
+      fields="title body"
+      permission="zope.ManageContent"
+      />
+
+  <addMenuItem
+      class="book.messageboard.message.Message"
+      title="Message"
+      description="A Message"
+      permission="zope.ManageContent"
+      view="AddMessage.html" 
+      />
+
+  <editform
+      schema="book.messageboard.interfaces.IMessage"
+      for="book.messageboard.interfaces.IMessage"
+      label="Change Message"
+      fields="title body"
+      name="edit.html"
+      permission="zope.ManageContent"
+      menu="zmi_views" title="Edit" 
+      />
+
+  <containerViews
+      for="book.messageboard.interfaces.IMessage"
+      index="zope.View"
+      contents="zope.View"
+      add="zope.ManageContent"
+      />
+
+</configure>

Added: messageboard/trunk/configure.zcml
===================================================================
--- messageboard/trunk/configure.zcml	2004-05-14 15:53:51 UTC (rev 24658)
+++ messageboard/trunk/configure.zcml	2004-05-14 15:58:20 UTC (rev 24659)
@@ -0,0 +1,54 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope">
+
+  <interface 
+      interface=".interfaces.IMessageBoard" 
+      type="zope.app.content.interfaces.IContentType"
+      /> 
+
+  <content class=".messageboard.MessageBoard">
+    <implements
+        interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+        />
+    <implements
+        interface="zope.app.container.interfaces.IContentContainer" 
+        />
+    <factory
+        id="book.messageboard.MessageBoard"
+        description="Message Board" 
+        />
+    <require
+        permission="zope.ManageContent"
+        interface=".interfaces.IMessageBoard"
+        />
+    <require
+        permission="zope.ManageContent"
+        set_schema=".interfaces.IMessageBoard"
+        />
+  </content>
+
+  <interface 
+      interface=".interfaces.IMessage" 
+      type="zope.app.content.interfaces.IContentType"
+      /> 
+
+  <content class=".message.Message">
+    <implements
+        interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+        />
+    <implements
+        interface="zope.app.container.interfaces.IContentContainer" 
+        />
+    <require
+        permission="zope.ManageContent"
+        interface=".interfaces.IMessage"
+        />
+    <require
+        permission="zope.ManageContent"
+        set_schema=".interfaces.IMessage"
+        />
+  </content>
+
+  <include package=".browser" />
+
+</configure>

Added: messageboard/trunk/interfaces.py
===================================================================
--- messageboard/trunk/interfaces.py	2004-05-14 15:53:51 UTC (rev 24658)
+++ messageboard/trunk/interfaces.py	2004-05-14 15:58:20 UTC (rev 24659)
@@ -0,0 +1,62 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Message Board Interfaces
+
+Interfaces for the Zope 3 based Message Board Package 
+
+$Id$
+"""
+from zope.schema import Text, TextLine, Field
+
+from zope.app.container.constraints import ContainerTypesConstraint
+from zope.app.container.constraints import ItemTypePrecondition
+from zope.app.container.interfaces import IContainer
+
+
+class IMessage(IContainer):
+    """A message object. It can contain its own responses."""
+
+    title = TextLine(
+        title=u"Title/Subject",
+        description=u"Title and/or subject of the message.",
+        default=u"",
+        required=True)
+
+    body = Text(
+        title=u"Message Body",
+        description=u"This is the actual message. Type whatever you wish.",
+        default=u"",
+        required=False)
+
+
+class IMessageBoard(IContainer):
+    """The message board is the base object for our package. It can only
+    contain IMessage objects."""
+
+    def __setitem__(name, object):
+        """Add a IMessage object."""
+
+    __setitem__.precondition = ItemTypePrecondition(IMessage)
+
+    description = Text(
+        title=u"Description",
+        description=u"A detailed description of the content of the board.",
+        default=u"",
+        required=False)
+
+
+IMessage['__setitem__'].setTaggedValue('precondition',
+                                       ItemTypePrecondition(IMessage))
+IMessage.setTaggedValue('__parent__', Field(
+    constraint=ContainerTypesConstraint(IMessageBoard, IMessage)))

Added: messageboard/trunk/message.py
===================================================================
--- messageboard/trunk/message.py	2004-05-14 15:53:51 UTC (rev 24658)
+++ messageboard/trunk/message.py	2004-05-14 15:58:20 UTC (rev 24659)
@@ -0,0 +1,54 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Message Implementation
+
+An implementation of the Message using BTreeContainers as base.
+
+$Id: message.py,v 1.1 2003/06/07 11:24:48 srichter Exp $
+"""
+from zope.interface import implements
+from zope.app.container.btree import BTreeContainer
+
+from book.messageboard.interfaces import IMessage
+
+class Message(BTreeContainer):
+    """A simple implementation of a message.
+
+    Make sure that the ``Message`` implements the ``IMessage`` interface:
+
+    >>> from zope.interface.verify import verifyClass
+    >>> verifyClass(IMessage, Message)
+    True
+
+    Here is an example of changing the title and description of the message:
+
+    >>> message = Message()
+    >>> message.title
+    u''
+    >>> message.body
+    u''
+    >>> message.title = u'Message Title'
+    >>> message.body = u'Message Body'
+    >>> message.title
+    u'Message Title'
+    >>> message.body
+    u'Message Body'
+    """
+    implements(IMessage)
+
+    # See book.messageboard.interfaces.IMessage
+    title = u''
+
+    # See book.messageboard.interfaces.IMessage
+    body = u''

Added: messageboard/trunk/messageboard.py
===================================================================
--- messageboard/trunk/messageboard.py	2004-05-14 15:53:51 UTC (rev 24658)
+++ messageboard/trunk/messageboard.py	2004-05-14 15:58:20 UTC (rev 24659)
@@ -0,0 +1,47 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Message Board Implementation
+
+An implementation of the Message Board using BTreeContainers as base.
+
+$Id$
+"""
+from zope.interface import implements
+from zope.app.container.btree import BTreeContainer
+
+from book.messageboard.interfaces import IMessageBoard
+
+class MessageBoard(BTreeContainer):
+    """A very simple implementation of a message board using B-Tree Containers
+
+    Make sure that the ``MessageBoard`` implements the ``IMessageBoard``
+    interface:
+
+    >>> from zope.interface.verify import verifyClass
+    >>> verifyClass(IMessageBoard, MessageBoard)
+    True
+    
+    Here is an example of changing the description of the board:
+
+    >>> board = MessageBoard()
+    >>> board.description
+    u''
+    >>> board.description = u'Message Board Description'
+    >>> board.description
+    u'Message Board Description'
+    """
+    implements(IMessageBoard)
+
+    # See book.messageboard.interfaces.IMessageBoard
+    description = u''

Added: messageboard/trunk/tests/__init__.py
===================================================================
--- messageboard/trunk/tests/__init__.py	2004-05-14 15:53:51 UTC (rev 24658)
+++ messageboard/trunk/tests/__init__.py	2004-05-14 15:58:20 UTC (rev 24659)
@@ -0,0 +1 @@
+# Make it a Python package

Added: messageboard/trunk/tests/test_message.py
===================================================================
--- messageboard/trunk/tests/test_message.py	2004-05-14 15:53:51 UTC (rev 24658)
+++ messageboard/trunk/tests/test_message.py	2004-05-14 15:58:20 UTC (rev 24659)
@@ -0,0 +1,38 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Message Board Tests
+
+$Id: test_message.py,v 1.2 2003/08/20 17:07:46 srichter Exp $
+"""
+import unittest
+from zope.testing.doctestunit import DocTestSuite
+
+from zope.app.container.tests.test_icontainer import TestSampleContainer
+
+from book.messageboard.message import Message
+
+
+class Test(TestSampleContainer):
+
+    def makeTestObject(self):
+        return Message()
+
+def test_suite():
+    return unittest.TestSuite((
+        DocTestSuite('book.messageboard.message'),
+        unittest.makeSuite(Test),
+        ))
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')

Added: messageboard/trunk/tests/test_messageboard.py
===================================================================
--- messageboard/trunk/tests/test_messageboard.py	2004-05-14 15:53:51 UTC (rev 24658)
+++ messageboard/trunk/tests/test_messageboard.py	2004-05-14 15:58:20 UTC (rev 24659)
@@ -0,0 +1,38 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Message Board Tests
+
+$Id: test_messageboard.py,v 1.2 2003/08/20 17:07:46 srichter Exp $
+"""
+import unittest
+from zope.testing.doctestunit import DocTestSuite
+
+from zope.app.container.tests.test_icontainer import TestSampleContainer
+
+from book.messageboard.messageboard import MessageBoard
+
+
+class Test(TestSampleContainer):
+
+    def makeTestObject(self):
+        return MessageBoard()
+
+def test_suite():
+    return unittest.TestSuite((
+        DocTestSuite('book.messageboard.messageboard'),
+        unittest.makeSuite(Test),
+        ))
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')




More information about the Zope-CVS mailing list