Back to index

plone3  3.1.7
NewsItem.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """ News content object.
00014 
00015 $Id: NewsItem.py 77186 2007-06-28 19:06:19Z yuppie $
00016 """
00017 
00018 from AccessControl import ClassSecurityInfo
00019 from Globals import InitializeClass
00020 from zope.component.factory import Factory
00021 from zope.interface import implements
00022 
00023 from Document import Document
00024 from interfaces import IMutableNewsItem
00025 from interfaces import INewsItem
00026 from permissions import ModifyPortalContent
00027 
00028 
00029 def addNewsItem( self
00030                , id
00031                , title=''
00032                , description=''
00033                , text=''
00034                , text_format=''
00035                ):
00036     """Add a NewsItem.
00037     """
00038     o=NewsItem( id=id
00039               , title=title
00040               , description=description
00041               , text=text
00042               , text_format=text_format
00043               )
00044     self._setObject(id, o)
00045 
00046 
00047 class NewsItem(Document):
00048 
00049     """A News Item.
00050     """
00051 
00052     implements(IMutableNewsItem, INewsItem)
00053     __implements__ = Document.__implements__  # redundant, but explicit
00054 
00055     text_format = 'html'
00056 
00057     security = ClassSecurityInfo()
00058 
00059     security.declareProtected(ModifyPortalContent, 'edit')
00060     def edit( self, text, description=None, text_format=None ):
00061         """Edit the News Item.
00062         """
00063         if text_format is None:
00064             text_format = getattr(self, 'text_format', 'structured-text')
00065         if description is not None:
00066             self.setDescription( description )
00067         Document.edit( self, text_format, text )
00068 
00069 InitializeClass(NewsItem)
00070 
00071 NewsItemFactory = Factory(NewsItem)