Back to index

plone3  3.1.7
folder.py
Go to the documentation of this file.
00001 #  ATContentTypes http://plone.org/products/atcontenttypes/
00002 #  Archetypes reimplementation of the CMF core types
00003 #  Copyright (c) 2003-2006 AT Content Types development team
00004 #
00005 #  This program is free software; you can redistribute it and/or modify
00006 #  it under the terms of the GNU General Public License as published by
00007 #  the Free Software Foundation; either version 2 of the License, or
00008 #  (at your option) any later version.
00009 #
00010 #  This program is distributed in the hope that it will be useful,
00011 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 #  GNU General Public License for more details.
00014 #
00015 #  You should have received a copy of the GNU General Public License
00016 #  along with this program; if not, write to the Free Software
00017 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 #
00019 """
00020 
00021 
00022 """
00023 __author__  = 'Christian Heimes <tiran@cheimes.de>'
00024 __docformat__ = 'restructuredtext'
00025 __old_name__ = 'Products.ATContentTypes.types.ATFolder'
00026 
00027 from AccessControl import ClassSecurityInfo
00028 
00029 from Products.ATContentTypes.config import PROJECTNAME
00030 from Products.ATContentTypes.content.base import registerATCT
00031 from Products.ATContentTypes.content.base import ATCTOrderedFolder
00032 from Products.ATContentTypes.content.base import ATCTBTreeFolder
00033 from Products.ATContentTypes.interfaces import IATFolder
00034 from Products.ATContentTypes.interfaces import IATBTreeFolder
00035 from Products.ATContentTypes.content.schemata import ATContentTypeSchema
00036 from Products.ATContentTypes.content.schemata import NextPreviousAwareSchema
00037 from Products.ATContentTypes.content.schemata import finalizeATCTSchema
00038 from Products.ATContentTypes.lib.constraintypes import ConstrainTypesMixinSchema
00039 from Products.ATContentTypes.lib.autosort import AutoSortSupport
00040 from Products.ATContentTypes.lib.autosort import AutoOrderSupport
00041 
00042 from Products.ATContentTypes import ATCTMessageFactory as _
00043 
00044 from Products.CMFCore.permissions import View
00045 
00046 ATFolderSchema      = ATContentTypeSchema.copy() + ConstrainTypesMixinSchema + NextPreviousAwareSchema
00047 ATBTreeFolderSchema = ATContentTypeSchema.copy() + ConstrainTypesMixinSchema
00048 
00049 finalizeATCTSchema(ATFolderSchema, folderish=True, moveDiscussion=False)
00050 finalizeATCTSchema(ATBTreeFolderSchema, folderish=True, moveDiscussion=False)
00051 
00052 
00053 class ATFolder(AutoOrderSupport, ATCTOrderedFolder):
00054     """A folder which can contain other items."""
00055 
00056     schema         =  ATFolderSchema
00057 
00058     portal_type    = 'Folder'
00059     archetype_name = 'Folder'
00060     _atct_newTypeFor = {'portal_type' : 'CMF Folder', 'meta_type' : 'Plone Folder'}
00061     assocMimetypes = ()
00062     assocFileExt   = ()
00063     cmf_edit_kws   = ()
00064 
00065     __implements__ = (ATCTOrderedFolder.__implements__, IATFolder,
00066                      AutoOrderSupport.__implements__)
00067 
00068     # Enable marshalling via WebDAV/FTP/ExternalEditor.
00069     __dav_marshall__ = True
00070 
00071     security       = ClassSecurityInfo()
00072 
00073     security.declareProtected(View, 'getNextPreviousParentValue')
00074     def getNextPreviousParentValue(self):
00075         """If the parent node is also an IATFolder and has next/previous
00076         navigation enabled, then let this folder have it enabled by
00077         default as well.
00078         """
00079         parent = self.getParentNode()
00080         from Products.ATContentTypes.interface.folder import IATFolder as IATFolder_
00081         if IATFolder_.providedBy(parent):
00082             return parent.getNextPreviousEnabled()
00083         else:
00084             return False
00085 
00086     def manage_afterAdd(self, item, container):
00087         ATCTOrderedFolder.manage_afterAdd(self, item, container)
00088         AutoOrderSupport.manage_afterAdd(self, item, container)
00089 
00090 registerATCT(ATFolder, PROJECTNAME)
00091 
00092 class ATBTreeFolder(AutoSortSupport, ATCTBTreeFolder):
00093     """A folder suitable for holding a very large number of items"""
00094     schema         =  ATBTreeFolderSchema
00095 
00096 
00097     portal_type    = 'Large Plone Folder'
00098     archetype_name = 'Large Folder'
00099     _atct_newTypeFor = {'portal_type' : 'CMF Large Plone Folder',
00100                         'meta_type' : 'Large Plone Folder'}
00101     assocMimetypes = ()
00102     assocFileExt   = ()
00103     cmf_edit_kws   = ()
00104 
00105     __implements__ = (ATCTBTreeFolder.__implements__, IATBTreeFolder,
00106                       AutoSortSupport.__implements__)
00107 
00108     # Enable marshalling via WebDAV/FTP/ExternalEditor.
00109     __dav_marshall__ = True
00110 
00111     security       = ClassSecurityInfo()
00112 
00113 registerATCT(ATBTreeFolder, PROJECTNAME)