Back to index

plone3  3.1.7
SkinnedFolder.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 """ Allow the "view" of a folder to be skinned by type.
00014 
00015 $Id: SkinnedFolder.py 68426 2006-06-01 09:25:43Z 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 Products.CMFCore.CMFCatalogAware import CMFCatalogAware
00024 from Products.CMFCore.interfaces import IContentish
00025 from Products.CMFCore.PortalFolder import PortalFolder
00026 
00027 from DublinCore import DefaultDublinCoreImpl
00028 from permissions import ModifyPortalContent
00029 from permissions import View
00030 
00031 
00032 class SkinnedFolder(CMFCatalogAware, PortalFolder):
00033 
00034     """ Skinned Folder class. 
00035     """
00036 
00037     implements(IContentish)
00038 
00039     security = ClassSecurityInfo()
00040 
00041     manage_options = PortalFolder.manage_options
00042 
00043     # XXX: maybe we should subclass from DefaultDublinCoreImpl or refactor it
00044 
00045     security.declarePrivate('notifyModified')
00046     def notifyModified(self):
00047         """ Take appropriate action after the resource has been modified.
00048 
00049         Update creators.
00050         """
00051         self.addCreator()
00052 
00053     security.declareProtected(ModifyPortalContent, 'addCreator')
00054     addCreator = DefaultDublinCoreImpl.addCreator.im_func
00055 
00056     security.declareProtected(View, 'listCreators')
00057     listCreators = DefaultDublinCoreImpl.listCreators.im_func
00058 
00059     security.declareProtected(View, 'Creator')
00060     Creator = DefaultDublinCoreImpl.Creator.im_func
00061 
00062     # We derive from CMFCatalogAware first, so we are cataloged too.
00063 
00064     #
00065     #   IContentish method
00066     #
00067 
00068     security.declareProtected(View, 'SearchableText')
00069     def SearchableText(self):
00070         """
00071         SeachableText is used for full text seraches of a portal.  It
00072         should return a concatenation of all useful text.
00073         """
00074         return "%s %s" % (self.title, self.description)
00075 
00076 InitializeClass(SkinnedFolder)
00077 
00078 SkinnedFolderFactory = Factory(SkinnedFolder)
00079 
00080 def addSkinnedFolder( self, id, title='', description='', REQUEST=None ):
00081     """
00082     """
00083     sf = SkinnedFolder( id, title )
00084     sf.description = description
00085     self._setObject( id, sf )
00086     sf = self._getOb( id )
00087     if REQUEST is not None:
00088         REQUEST['RESPONSE'].redirect( sf.absolute_url() + '/manage_main' )