Back to index

plone3  3.1.7
BaseBTreeFolder.py
Go to the documentation of this file.
00001 from Products.Archetypes import WebDAVSupport
00002 from Products.Archetypes.atapi import BaseFolder
00003 from Products.Archetypes.interfaces import IBaseFolder
00004 from Products.CMFCore import permissions
00005 from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder
00006 from AccessControl import ClassSecurityInfo
00007 from Globals import InitializeClass
00008 from zope.interface import implements
00009 
00010 # to keep backward compatibility
00011 has_btree = 1
00012 
00013 from webdav.NullResource import NullResource
00014 from OFS.ObjectManager import REPLACEABLE
00015 from ComputedAttribute import ComputedAttribute
00016 
00017 class BaseBTreeFolder(CMFBTreeFolder, BaseFolder):
00018     """ A BaseBTreeFolder with all the bells and whistles"""
00019 
00020     security = ClassSecurityInfo()
00021 
00022     __implements__ = CMFBTreeFolder.__implements__, BaseFolder.__implements__
00023     implements(IBaseFolder)
00024 
00025     # Fix permissions set by CopySupport.py
00026     __ac_permissions__ = (
00027         (permissions.ModifyPortalContent,
00028          ('manage_cutObjects', 'manage_pasteObjects',
00029           'manage_renameObject', 'manage_renameObjects',)),
00030         )
00031     security.declareProtected('Copy or Move', 'manage_copyObjects')
00032 
00033     def __init__(self, oid, **kwargs):
00034         CMFBTreeFolder.__init__(self, oid)
00035         BaseFolder.__init__(self, oid, **kwargs)
00036 
00037     security.declarePrivate('manage_afterAdd')
00038     def manage_afterAdd(self, item, container):
00039         # CMFBTreeFolder inherits from PortalFolder, which has the same
00040         # base class as SkinnedFolder, and SkinnedFolder doesn't
00041         # override any of those methods, so just calling
00042         # BaseFolder.manage* should do it.
00043         BaseFolder.manage_afterAdd(self, item, container)
00044 
00045     security.declarePrivate('manage_afterClone')
00046     def manage_afterClone(self, item):
00047         # CMFBTreeFolder inherits from PortalFolder, which has the same
00048         # base class as SkinnedFolder, and SkinnedFolder doesn't
00049         # override any of those methods, so just calling
00050         # BaseFolder.manage* should do it.
00051         BaseFolder.manage_afterClone(self, item)
00052 
00053     security.declarePrivate('manage_beforeDelete')
00054     def manage_beforeDelete(self, item, container):
00055         # CMFBTreeFolder inherits from PortalFolder, which has the same
00056         # base class as SkinnedFolder, and SkinnedFolder doesn't
00057         # override any of those methods, so just calling
00058         # BaseFolder.manage* should do it.
00059         BaseFolder.manage_beforeDelete(self, item, container)
00060 
00061     def _getCopy(self, container):
00062         # We need to take _getCopy from BaseFolder (implicitly from
00063         # Referenceable) instead of straight from PortalFolder, otherwise there
00064         # are strange side effects with references on copy.
00065         return BaseFolder._getCopy(self, container)
00066 
00067     def _notifyOfCopyTo(self, container, op=0):
00068         # We need to take _notifyOfCopyTo from BaseFolder (implicitly from
00069         # Referenceable) instead of straight from PortalFolder, otherwise there
00070         # are strange side effects with references on copy.
00071         return BaseFolder._notifyOfCopyTo(self, container, op)
00072 
00073     def __getitem__(self, key):
00074         """ Override BTreeFolder __getitem__ """
00075         if key in self.Schema().keys() and key[:1] != "_": #XXX 2.2
00076             accessor = self.Schema()[key].getAccessor(self)
00077             if accessor is not None:
00078                 return accessor()
00079         return CMFBTreeFolder.__getitem__(self, key)
00080 
00081     security.declareProtected(permissions.ModifyPortalContent, 'indexObject')
00082     indexObject = BaseFolder.indexObject.im_func
00083 
00084     security.declareProtected(permissions.ModifyPortalContent, 'unindexObject')
00085     unindexObject = BaseFolder.unindexObject.im_func
00086 
00087     security.declareProtected(permissions.ModifyPortalContent, 'reindexObject')
00088     reindexObject = BaseFolder.reindexObject.im_func
00089 
00090     security.declareProtected(permissions.ModifyPortalContent, 'reindexObjectSecurity')
00091     reindexObjectSecurity = BaseFolder.reindexObjectSecurity.im_func
00092 
00093     security.declarePrivate('notifyWorkflowCreated')
00094     notifyWorkflowCreated = BaseFolder.notifyWorkflowCreated.im_func
00095 
00096     security.declareProtected(permissions.AccessContentsInformation, 'opaqueItems')
00097     opaqueItems = BaseFolder.opaqueItems.im_func
00098 
00099     security.declareProtected(permissions.AccessContentsInformation, 'opaqueIds')
00100     opaqueIds = BaseFolder.opaqueIds.im_func
00101 
00102     security.declareProtected(permissions.AccessContentsInformation, 'opaqueValues')
00103     opaqueValues = BaseFolder.opaqueValues.im_func
00104 
00105     security.declareProtected(permissions.ListFolderContents, 'listFolderContents')
00106     listFolderContents = BaseFolder.listFolderContents.im_func
00107 
00108     security.declareProtected(permissions.AccessContentsInformation,
00109                               'folderlistingFolderContents')
00110     folderlistingFolderContents = BaseFolder.folderlistingFolderContents.im_func
00111 
00112     __call__ = BaseFolder.__call__.im_func
00113 
00114     #security.declareProtected(permissions.View, 'view')
00115     #view = BaseFolder.view.im_func
00116 
00117     def index_html(self):
00118         """ Allow creation of .
00119         """
00120         if self.has_key('index_html'):
00121             return self._getOb('index_html')
00122         request = getattr(self, 'REQUEST', None)
00123         if request and request.has_key('REQUEST_METHOD'):
00124             if (request.maybe_webdav_client and
00125                 request['REQUEST_METHOD'] in  ['PUT']):
00126                 # Very likely a WebDAV client trying to create something
00127                 nr = NullResource(self, 'index_html')
00128                 nr.__replaceable__ = REPLACEABLE
00129                 return nr
00130         return None
00131 
00132     index_html = ComputedAttribute(index_html, 1)
00133 
00134     security.declareProtected(permissions.View, 'Title')
00135     Title = BaseFolder.Title.im_func
00136 
00137     security.declareProtected(permissions.ModifyPortalContent, 'setTitle')
00138     setTitle = BaseFolder.setTitle.im_func
00139 
00140     security.declareProtected(permissions.View, 'title_or_id')
00141     title_or_id = BaseFolder.title_or_id.im_func
00142 
00143     security.declareProtected(permissions.View, 'Description')
00144     Description = BaseFolder.Description.im_func
00145 
00146     security.declareProtected(permissions.ModifyPortalContent, 'setDescription')
00147     setDescription = BaseFolder.setDescription.im_func
00148 
00149     manage_addFolder = BaseFolder.manage_addFolder.im_func
00150 
00151     MKCOL = BaseFolder.MKCOL.im_func
00152     MKCOL_handler = BaseFolder.MKCOL_handler.im_func
00153 
00154     security.declareProtected(permissions.ModifyPortalContent, 'PUT')
00155     PUT = WebDAVSupport.PUT
00156 
00157     security.declareProtected(permissions.View, 'manage_FTPget')
00158     manage_FTPget = WebDAVSupport.manage_FTPget
00159 
00160     security.declarePrivate('manage_afterPUT')
00161     manage_afterPUT = WebDAVSupport.manage_afterPUT
00162 
00163     security.declareProtected(permissions.ModifyPortalContent, 'edit')
00164     edit = BaseFolder.edit.im_func
00165 
00166 InitializeClass(BaseBTreeFolder)
00167 
00168 BaseBTreeFolderSchema = BaseBTreeFolder.schema
00169 
00170 __all__ = ('BaseBTreeFolder', 'BaseBTreeFolderSchema', )