[Zope3-checkins] SVN: messageboard/trunk/step01/ Changed
preconditions and constraints to be described by two new
Stephan Richter
srichter at cosmos.phy.tufts.edu
Tue Aug 10 17:14:43 EDT 2004
Log message for revision 26980:
Changed preconditions and constraints to be described by two new
interfaces.
Changed:
U messageboard/trunk/step01/configure.zcml
U messageboard/trunk/step01/interfaces.py
U messageboard/trunk/step01/message.py
-=-
Modified: messageboard/trunk/step01/configure.zcml
===================================================================
--- messageboard/trunk/step01/configure.zcml 2004-08-10 20:05:11 UTC (rev 26979)
+++ messageboard/trunk/step01/configure.zcml 2004-08-10 21:14:43 UTC (rev 26980)
@@ -45,6 +45,10 @@
/>
<require
permission="zope.ManageContent"
+ interface=".interfaces.IMessageContainer"
+ />
+ <require
+ permission="zope.ManageContent"
set_schema=".interfaces.IMessage"
/>
</content>
Modified: messageboard/trunk/step01/interfaces.py
===================================================================
--- messageboard/trunk/step01/interfaces.py 2004-08-10 20:05:11 UTC (rev 26979)
+++ messageboard/trunk/step01/interfaces.py 2004-08-10 21:14:43 UTC (rev 26980)
@@ -17,20 +17,19 @@
$Id$
"""
+
+from zope.interface import Interface
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
+from zope.app.container.interfaces import IContained, IContainer
from zope.app.file.interfaces import IFile
-class IMessage(IContainer):
- """A message object. It can contain its own responses."""
+class IMessage(Interface):
+ """A message object."""
- def __setitem__(name, object):
- """Add a IMessage object."""
-
title = TextLine(
title=u"Title/Subject",
description=u"Title and/or subject of the message.",
@@ -60,7 +59,18 @@
required=False)
-IMessage['__setitem__'].setTaggedValue('precondition',
- ItemTypePrecondition(IMessage, IFile))
-IMessage.setTaggedValue('__parent__', Field(
- constraint=ContainerTypesConstraint(IMessageBoard, IMessage)))
+class IMessageContained(IContained):
+ """Interface that specifies the type of objects that can contain
+ messages."""
+ __parent__ = Field(
+ constraint = ContainerTypesConstraint(IMessageBoard, IMessage))
+
+
+class IMessageContainer(IContainer):
+ """We also want to make the message object a container that can contain
+ responses (other messages) and attachments (files and images)."""
+
+ def __setitem__(name, object):
+ """Add a IMessage object."""
+
+ __setitem__.precondition = ItemTypePrecondition(IMessage, IFile)
Modified: messageboard/trunk/step01/message.py
===================================================================
--- messageboard/trunk/step01/message.py 2004-08-10 20:05:11 UTC (rev 26979)
+++ messageboard/trunk/step01/message.py 2004-08-10 21:14:43 UTC (rev 26980)
@@ -21,6 +21,7 @@
from zope.app.container.btree import BTreeContainer
from book.messageboard.interfaces import IMessage
+from book.messageboard.interfaces import IMessageContained, IMessageContainer
class Message(BTreeContainer):
"""A simple implementation of a message.
@@ -45,7 +46,7 @@
>>> message.body
u'Message Body'
"""
- implements(IMessage)
+ implements(IMessage, IMessageContained, IMessageContainer)
# See book.messageboard.interfaces.IMessage
title = u''
More information about the Zope3-Checkins
mailing list