From 96b058bfea40a35981a9f48ecf20d4d6f46412f2 Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Wed, 17 Dec 2003 22:14:16 +0000 Subject: [PATCH] Improved renaming support Patch fixed a bit git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@127 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/Base.py | 8 ++++++-- product/ERP5Type/CopySupport.py | 22 ++++++++++++++++++++++ product/ERP5Type/ZopePatch.py | 6 +++--- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py index b0fed118d2..b5c103e21b 100755 --- a/product/ERP5Type/Base.py +++ b/product/ERP5Type/Base.py @@ -466,14 +466,18 @@ class Base( CopyContainer, PortalContent, Base18, ActiveObject, ERP5PropertyMana if old_value != kw[key] or force_update: self._setProperty(key, kw[key]) elif self.id != kw['id']: - self.flushActivity(invoke=1) # Do not rename until everything flushed + self.recursiveFlushActivity(invoke=1) # Do not rename until everything flushed previous_relative_url = self.getRelativeUrl() self.aq_parent.manage_renameObjects([self.id], [kw['id']]) new_relative_url = self.getRelativeUrl() id_changed = 1 self.reindexObject() if id_changed: - self.flushActivity(invoke=1) # Required if we wish that news ids appear instantly + self.recursiveFlushActivity(invoke=1) # Required if we wish that news ids appear instantly + #if self.isIndexable: + # self.moveObject() # Required if we wish that news ids appear instantly + #if hasattr(aq_base(self), 'recursiveMoveObject'): + # self.recursiveMoveObject() # Required to make sure path of subobjects is updated self.activate().updateRelatedContent(previous_relative_url, new_relative_url) #self.activate().recursiveImmediateReindexObject() # Required to update path / relative_url of subobjects diff --git a/product/ERP5Type/CopySupport.py b/product/ERP5Type/CopySupport.py index 0d41a707f9..c59c00db6d 100755 --- a/product/ERP5Type/CopySupport.py +++ b/product/ERP5Type/CopySupport.py @@ -174,3 +174,25 @@ class CopyContainer: catalog.unindexObject(self, path=path) #LOG("unindexObject",0, str(self.id)) + security.declareProtected(Permissions.ModifyPortalContent, 'moveObject') + def moveObject(self, idxs=[]): + """ + Reindex the object in the portal catalog. + If idxs is present, only those indexes are reindexed. + The metadata is always updated. + + Also update the modification date of the object, + unless specific indexes were requested. + + Passes is_object_moved to catalog to force + reindexing without creating new uid + """ + if idxs == []: + # Update the modification date. + if hasattr(aq_base(self), 'notifyModified'): + self.notifyModified() + catalog = getToolByName(self, 'portal_catalog', None) + if catalog is not None: + catalog.moveObject(self, idxs=idxs) + + diff --git a/product/ERP5Type/ZopePatch.py b/product/ERP5Type/ZopePatch.py index d843768854..a5cfbc6257 100755 --- a/product/ERP5Type/ZopePatch.py +++ b/product/ERP5Type/ZopePatch.py @@ -217,8 +217,8 @@ class_file:%s # This function doesn't take care about properties by default def PUT(self, REQUEST, RESPONSE): """Handle put requests""" - self.dav__init(REQUEST, RESPONSE) - self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1) + if RESPONSE is not None: self.dav__init(REQUEST, RESPONSE) + if RESPONSE is not None: self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1) body = REQUEST.get('BODY', '') m = re.match('\s*<dtml-comment>(.*)</dtml-comment>\s*\n', body, re.I | re.S) if m: @@ -251,7 +251,7 @@ class_file:%s self.template=t=self.template_class(template) t.cook() self._v_cache={}, Bucket() - RESPONSE.setStatus(204) + if RESPONSE is not None: RESPONSE.setStatus(204) return RESPONSE -- 2.30.9