From b98bbbbfac7431e877fcc5ecfba3de77ec1e935e Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Thu, 16 Aug 2007 00:43:18 +0000 Subject: [PATCH] New WebDAV PUT method handles much better catalog and uid related issues in ContributionTool. The main difference with the standard one is that we call here constructContent with is_indexable=0. This way, documents which are created are not indexed. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15685 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/Core/Folder.py | 4 ++- product/ERP5Type/WebDAVSupport.py | 43 ++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/product/ERP5Type/Core/Folder.py b/product/ERP5Type/Core/Folder.py index 0f220604a4..c2a003ade5 100644 --- a/product/ERP5Type/Core/Folder.py +++ b/product/ERP5Type/Core/Folder.py @@ -41,6 +41,7 @@ from Products.ERP5Type import PropertySheet, Permissions from Products.ERP5Type.XMLExportImport import Folder_asXML from Products.ERP5Type.Cache import CachingMethod from Products.ERP5Type.Utils import sortValueList +from Products.ERP5Type.WebDAVSupport import Folder as WebDAVFolder try: from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder @@ -294,7 +295,7 @@ class FolderMixIn(ExtensionClass.Base): """ return self.countFolder(**kw)[0][0] -class Folder( CopyContainer, CMFBTreeFolder, Base, FolderMixIn): +class Folder( CopyContainer, CMFBTreeFolder, Base, FolderMixIn, WebDAVFolder): """ A Folder is a subclass of Base but not of XMLObject. Folders are not considered as documents and are therefore @@ -353,6 +354,7 @@ class Folder( CopyContainer, CMFBTreeFolder, Base, FolderMixIn): _edit = Base._edit _setPropValue = Base._setPropValue _propertyMap = Base._propertyMap # are there any others XXX ? + PUT_factory = WebDAVFolder.PUT_factory # XXX Prevent inheritance from PortalFolderBase description = None diff --git a/product/ERP5Type/WebDAVSupport.py b/product/ERP5Type/WebDAVSupport.py index 88b9730b7d..0f5dc8906c 100644 --- a/product/ERP5Type/WebDAVSupport.py +++ b/product/ERP5Type/WebDAVSupport.py @@ -13,9 +13,11 @@ ############################################################################## import re +from Acquisition import aq_parent, aq_inner, aq_base from AccessControl import ClassSecurityInfo, ModuleSecurityInfo from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.CMFCore.PortalContent import NoWL, ResourceLockedError +from Products.CMFCore.utils import getToolByName from Products.CMFDefault.utils import parseHeadersBody from Products.CMFDefault.utils import html_headcheck from Products.CMFDefault.utils import bodyfinder @@ -189,4 +191,43 @@ class TextContent: security.declareProtected(Permissions.View, 'get_size') def get_size( self ): """ Used for FTP and apparently the ZMI now too """ - return len(self.manage_FTPget()) \ No newline at end of file + return len(self.manage_FTPget()) + + +class Folder: + """ + Taken from CMFCore.PortalFolder + """ + def PUT_factory( self, name, typ, body ): + """ Factory for PUT requests to objects which do not yet exist. + + Used by NullResource.PUT. + + Returns -- Bare and empty object of the appropriate type (or None, if + we don't know what to do) + """ + registry = getToolByName(self, 'content_type_registry', None) + if registry is None: + return None + + portal_type = registry.findTypeName( name, typ, body ) + if portal_type is None: + return None + + # The code bellow is inspired from ERP5Type.Core.Folder.newContent + pt = self._getTypesTool() + myType = pt.getTypeInfo(self) + if myType is not None and not myType.allowType( portal_type ) and \ + 'portal_trash' not in self.getPhysicalPath(): + raise ValueError('Disallowed subobject type: %s' % portal_type) + pt.constructContent( type_name=portal_type, + container=self, + id=name, + is_indexable=0 + ) # **kw) removed due to CMF bug + + # constructContent does too much, so the object has to be removed again + obj = aq_base( self._getOb( name ) ) + self._delObject( name ) # _delObject will not invoke the catalog since is_indexable was set to 0 + delattr(obj, 'isIndexable') # Allow indexing again (standard case) + return obj -- 2.30.9