Back to index

plone3  3.1.7
LargePloneFolder.py
Go to the documentation of this file.
00001 from Acquisition import aq_base, aq_inner, aq_parent
00002 from ComputedAttribute import ComputedAttribute
00003 from Globals import InitializeClass
00004 from PloneFolder import BasePloneFolder, ReplaceableWrapper
00005 from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2Base
00006 from Products.CMFPlone.utils import log_deprecated
00007 
00008 
00009 class LargePloneFolder(BTreeFolder2Base, BasePloneFolder):
00010     """ A large plone folder """
00011     meta_type='Large Plone Folder'
00012 
00013     # BTreeFolder2Base has no __implements__
00014     __implements__ = BasePloneFolder.__implements__
00015 
00016     def __init__(self, id, title=''):
00017         # BBB To be removed in Plone 4.0
00018         log_deprecated("LargePloneFolder is deprecated and will be removed in "
00019                        "Plone 4.0. Please use ATBTreeFolder from ATCT instead.")
00020         BTreeFolder2Base.__init__(self, id)
00021         BasePloneFolder.__init__(self, id, title)
00022         self.id=id
00023         self.title=title
00024 
00025     # as per CMFBTreeFolder.py
00026     def _checkId(self, id, allow_dup=0):
00027         BasePloneFolder._checkId(self, id, allow_dup)
00028         BTreeFolder2Base._checkId(self, id, allow_dup)
00029 
00030     manage_renameObject = BasePloneFolder.inheritedAttribute('manage_renameObject')
00031     manage_delObjects = BasePloneFolder.inheritedAttribute('manage_delObjects')
00032 
00033     # this works around a problem that makes empty folders
00034     # evaluate to false in boolean tests, like:
00035     # tal:condition="python: someFolder and someFolder.someMethod(...)"
00036     __len__ = BasePloneFolder.__len__
00037 
00038 
00039     def index_html(self):
00040         """
00041         btree folders don't store objects as attributes, the implementation of index_html
00042         method in plone folder assumes this and by virtue of its being invoked looked in
00043         the parent container. we override here to check the btree data structs, and then
00044         perform the same lookup as BasePloneFolder if we don't find it.
00045         """
00046         _target = self.get('index_html')
00047         if _target is not None:
00048             return _target
00049         _target = aq_parent(aq_inner(self)).aq_acquire('index_html')
00050         return ReplaceableWrapper(aq_base(_target).__of__(self))
00051 
00052     index_html = ComputedAttribute(index_html, 1)
00053 
00054 InitializeClass(LargePloneFolder)
00055 
00056 def addLargePloneFolder(self, id, title='', description='', REQUEST=None):
00057     """ add a BTree-backed Plone Folder """
00058     # BBB To be removed in Plone 4.0
00059     log_deprecated("LargePloneFolder is deprecated and will be removed in "
00060                    "Plone 4.0. Please use ATBTreeFolder from ATCT instead.")
00061 
00062     obj = LargePloneFolder(id, title=title)
00063     obj.setDescription(description)
00064     self._setObject(id, obj)
00065     if REQUEST is not None:
00066         REQUEST['RESPONSE'].redirect( self.absolute_url() + '/manage_main' )