Commit 96b058bf authored by Jean-Paul Smets's avatar Jean-Paul Smets

Improved renaming support

Patch fixed a bit


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@127 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e64d2427
...@@ -466,14 +466,18 @@ class Base( CopyContainer, PortalContent, Base18, ActiveObject, ERP5PropertyMana ...@@ -466,14 +466,18 @@ class Base( CopyContainer, PortalContent, Base18, ActiveObject, ERP5PropertyMana
if old_value != kw[key] or force_update: if old_value != kw[key] or force_update:
self._setProperty(key, kw[key]) self._setProperty(key, kw[key])
elif self.id != kw['id']: 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() previous_relative_url = self.getRelativeUrl()
self.aq_parent.manage_renameObjects([self.id], [kw['id']]) self.aq_parent.manage_renameObjects([self.id], [kw['id']])
new_relative_url = self.getRelativeUrl() new_relative_url = self.getRelativeUrl()
id_changed = 1 id_changed = 1
self.reindexObject() self.reindexObject()
if id_changed: 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().updateRelatedContent(previous_relative_url, new_relative_url)
#self.activate().recursiveImmediateReindexObject() # Required to update path / relative_url of subobjects #self.activate().recursiveImmediateReindexObject() # Required to update path / relative_url of subobjects
......
...@@ -174,3 +174,25 @@ class CopyContainer: ...@@ -174,3 +174,25 @@ class CopyContainer:
catalog.unindexObject(self, path=path) catalog.unindexObject(self, path=path)
#LOG("unindexObject",0, str(self.id)) #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)
...@@ -217,8 +217,8 @@ class_file:%s ...@@ -217,8 +217,8 @@ class_file:%s
# This function doesn't take care about properties by default # This function doesn't take care about properties by default
def PUT(self, REQUEST, RESPONSE): def PUT(self, REQUEST, RESPONSE):
"""Handle put requests""" """Handle put requests"""
self.dav__init(REQUEST, RESPONSE) if RESPONSE is not None: self.dav__init(REQUEST, RESPONSE)
self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1) if RESPONSE is not None: self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1)
body = REQUEST.get('BODY', '') body = REQUEST.get('BODY', '')
m = re.match('\s*<dtml-comment>(.*)</dtml-comment>\s*\n', body, re.I | re.S) m = re.match('\s*<dtml-comment>(.*)</dtml-comment>\s*\n', body, re.I | re.S)
if m: if m:
...@@ -251,7 +251,7 @@ class_file:%s ...@@ -251,7 +251,7 @@ class_file:%s
self.template=t=self.template_class(template) self.template=t=self.template_class(template)
t.cook() t.cook()
self._v_cache={}, Bucket() self._v_cache={}, Bucket()
RESPONSE.setStatus(204) if RESPONSE is not None: RESPONSE.setStatus(204)
return RESPONSE return RESPONSE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment