Commit c988b9a2 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Define manage_renameObject in ERP5Site. Note that this implementation is good...

Define manage_renameObject in ERP5Site. Note that this implementation is good enough for the unit test, but far from perfect. The future implementation must use activities very carefully to reduce the memory footprint.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16727 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 770a4d6a
...@@ -31,6 +31,7 @@ from Products.ERP5Type.Cache import CachingMethod ...@@ -31,6 +31,7 @@ from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type.ERP5Type import ERP5TypeInformation from Products.ERP5Type.ERP5Type import ERP5TypeInformation
from Products.ERP5.Document.BusinessTemplate import BusinessTemplate from Products.ERP5.Document.BusinessTemplate import BusinessTemplate
from Products.ERP5Type.Log import log as unrestrictedLog from Products.ERP5Type.Log import log as unrestrictedLog
from Products.CMFActivity.Errors import ActivityPendingError
import ERP5Defaults import ERP5Defaults
from zLOG import LOG, INFO from zLOG import LOG, INFO
...@@ -208,6 +209,41 @@ class ERP5Site(FolderMixIn, CMFSite): ...@@ -208,6 +209,41 @@ class ERP5Site(FolderMixIn, CMFSite):
""" """
return self.index_html() return self.index_html()
security.declareProtected( Permissions.ModifyPortalContent, 'manage_renameObject' )
def manage_renameObject(self, id=None, new_id=None, REQUEST=None):
"""manage renaming an object while keeping coherency for contained
and linked to objects inside the renamed object.
XXX this is nearly a copy-and-paste from CopySupport.
XXX this is not good enough when the module or the objects inside
the module are referred to by outer objects. But addressing this problem
requires a full traversal of the object tree, and the current
implementation is not efficient enough for this.
"""
ob = self.restrictedTraverse(id)
if getattr(aq_base(ob), '_updateInternalRelatedContent', None) is not None:
# Make sure there is no activities pending on that object
try:
portal_activities = getToolByName(self, 'portal_activities')
except AttributeError:
# There is no activity tool
portal_activities = None
if portal_activities is not None:
if portal_activities.countMessage(path=ob.getPath())>0:
raise ActivityPendingError, 'Sorry, pending activities prevent ' \
+ 'changing id at this current stage'
# Search for categories that have to be updated in sub objects.
ob._recursiveSetActivityAfterTag(ob)
path_item_list = ob.getRelativeUrl().split('/')
ob._updateInternalRelatedContent(object=ob,
path_item_list=path_item_list,
new_id=new_id)
# Rename the object
return CMFSite.manage_renameObject(self, id=id, new_id=new_id,
REQUEST=REQUEST)
def _getAcquireLocalRoles(self): def _getAcquireLocalRoles(self):
""" """
Prevent local roles from being acquired outside of Portal object. Prevent local roles from being acquired outside of Portal object.
......
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