Back to index

plone3  3.1.7
SyndicationTool.py
Go to the documentation of this file.
00001 from Products.CMFDefault.SyndicationTool import SyndicationTool as BaseTool
00002 from Products.CMFPlone import ToolNames
00003 from Products.CMFCore.permissions import ManageProperties
00004 from Products.CMFCore.utils import getToolByName
00005 from AccessControl import ClassSecurityInfo, Unauthorized
00006 from Globals import InitializeClass
00007 from Products.CMFPlone.PloneBaseTool import PloneBaseTool
00008 
00009 
00010 class SyndicationTool(PloneBaseTool, BaseTool):
00011 
00012     meta_type = ToolNames.SyndicationTool
00013     security = ClassSecurityInfo()
00014     toolicon = 'skins/plone_images/rss.gif'
00015 
00016     __implements__ = (PloneBaseTool.__implements__, BaseTool.__implements__, )
00017 
00018     security.declarePublic('getSyndicatableContent')
00019     def getSyndicatableContent(self, obj):
00020         """ Use the getFolderContents script, unless
00021         an object (like Topic) overrides it
00022         """
00023         # should we be doing aq_base here?
00024         if hasattr(obj, 'synContentValues'):
00025             values = obj.synContentValues()
00026         else:
00027             values = obj.getFolderContents()
00028         return values
00029 
00030     # Add protection to these methods to allow only appropriate users
00031     # to set syndication properties
00032     def enableSyndication(self, obj):
00033         """
00034         Enable syndication for the obj
00035         """
00036         mtool = getToolByName(self, 'portal_membership')
00037         if not mtool.checkPermission(ManageProperties, obj):
00038             raise Unauthorized
00039         BaseTool.enableSyndication(self, obj)
00040 
00041     def disableSyndication(self, obj):
00042         """
00043         Disable syndication for the obj; and remove it.
00044         """
00045         mtool = getToolByName(self, 'portal_membership')
00046         if not mtool.checkPermission(ManageProperties, obj):
00047             raise Unauthorized
00048         BaseTool.disableSyndication(self, obj)
00049 
00050 SyndicationTool.__doc__ = BaseTool.__doc__
00051 
00052 InitializeClass(SyndicationTool)