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 IContained, IContainer class IBlogEntry(Interface): """Interface for blog entry objects.""" title = TextLine( title = u"Blog entry title", description = u"Blog entry title.", default = u"", required = True) content = Text( title = u"Blog entry content", description = u"Blog entry content.", default = u"", required = True) summary = Text( title = u"Summary", description = u"An excerpt from content.""", default = u"", max_length = 250, required = False) class IBlog(IContainer): """The blog container which can contain IBlogEntry objects.""" def __setitem__(name, object): """Add a IBlogEntry object.""" __setitem__.precondition = ItemTypePrecondition(IBlogEntry) title = TextLine( title = u"Blog title", description = u"Blog description", default = u"", required = True) description = Text( title = u"Description", description = u"A detailed description of the blog's contents.", default = u"", required = False) class IBlogEntryContained(IContained): """Interface that specifies which type of objects can contain blog entries.""" __parent__ = Field(constraint = ContainerTypesConstraint(IBlog))