Back to index

plone3  3.1.7
CMFBTreeFolder.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
00004 # All Rights Reserved.
00005 #
00006 # This software is subject to the provisions of the Zope Public License,
00007 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
00008 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00009 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00010 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00011 # FOR A PARTICULAR PURPOSE
00012 #
00013 ##############################################################################
00014 """CMFBTreeFolder
00015 
00016 $Id: CMFBTreeFolder.py 76503 2007-06-08 15:08:29Z jens $
00017 """
00018 
00019 from AccessControl.SecurityInfo import ClassSecurityInfo
00020 from Globals import InitializeClass
00021 from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2Base
00022 from zope.component.factory import Factory
00023 
00024 from permissions import AddPortalFolders
00025 from PortalFolder import PortalFolder
00026 from PortalFolder import PortalFolderBase
00027 
00028 
00029 def manage_addCMFBTreeFolder(dispatcher, id, title='', REQUEST=None):
00030     """Adds a new BTreeFolder object with id *id*.
00031     """
00032     id = str(id)
00033     ob = CMFBTreeFolder(id)
00034     ob.title = str(title)
00035     dispatcher._setObject(id, ob)
00036     ob = dispatcher._getOb(id)
00037     if REQUEST is not None:
00038         REQUEST['RESPONSE'].redirect(ob.absolute_url() + '/manage_main' )
00039 
00040 
00041 class CMFBTreeFolder(BTreeFolder2Base, PortalFolderBase):
00042 
00043     """BTree folder for CMF sites.
00044     """
00045 
00046     security = ClassSecurityInfo()
00047 
00048     def __init__(self, id, title=''):
00049         PortalFolderBase.__init__(self, id, title)
00050         BTreeFolder2Base.__init__(self, id)
00051 
00052     def _checkId(self, id, allow_dup=0):
00053         PortalFolderBase._checkId(self, id, allow_dup)
00054         BTreeFolder2Base._checkId(self, id, allow_dup)
00055 
00056     security.declareProtected(AddPortalFolders, 'manage_addPortalFolder')
00057     def manage_addPortalFolder(self, id, title='', REQUEST=None):
00058         """Add a new PortalFolder object with id *id*.
00059         """
00060         ob = PortalFolder(id, title)
00061         self._setObject(id, ob)
00062         if REQUEST is not None:
00063             return self.folder_contents( # XXX: ick!
00064                 self, REQUEST, portal_status_message="Folder added")
00065 
00066 InitializeClass(CMFBTreeFolder)
00067 
00068 CMFBTreeFolderFactory = Factory(CMFBTreeFolder)