[Erp5-report] r11691 - /erp5/trunk/products/ERP5Type/CopySupport.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Dec 12 14:59:01 CET 2006
Author: romain
Date: Tue Dec 12 14:59:00 2006
New Revision: 11691
URL: http://svn.erp5.org?rev=11691&view=rev
Log:
When doing copy/paste, check the relation of the subobjects, and update them if necessary.
A volatile attribute is used because of the limitation of CopySupport API.
Modified:
erp5/trunk/products/ERP5Type/CopySupport.py
Modified: erp5/trunk/products/ERP5Type/CopySupport.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/CopySupport.py?rev=11691&r1=11690&r2=11691&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/CopySupport.py (original)
+++ erp5/trunk/products/ERP5Type/CopySupport.py Tue Dec 12 14:59:00 2006
@@ -138,7 +138,9 @@
# Search for categories that have to be updated in sub objects.
self._recursiveSetActivityAfterTag(ob)
- self._updateInternalRelatedContent(local_self=ob, path=ob.getRelativeUrl().split("/"), new_id=new_id)
+ self._updateInternalRelatedContent(local_self=ob,
+ path=ob.getRelativeUrl().split("/"),
+ new_id=new_id)
#ob._v_is_renamed = 1
# Rename the object
return OriginalCopyContainer.manage_renameObject(self, id=id, new_id=new_id, REQUEST=REQUEST)
@@ -370,17 +372,37 @@
self._v_category_url_before_move = self.getRelativeUrl()
self._recursiveSetActivityAfterTag(self)
+ def _setId(self, id):
+ # Called to set the new id of a copied object.
+ # XXX It is bad to use volatile attribute, because we may have naming
+ # conflict later.
+ # Currently, it is required to use this volatile attribute
+ # when we do a copy/paste, in order to change the relation in _postCopy.
+ # Such implementation is due to the limitation of CopySuport API, which prevent
+ # to pass parameter to manage_afterClone.
+ self._v_previous_id = self.id
+ self.id=id
+
def _postCopy(self, container, op=0):
- # Called after the copy is finished to accomodate special cases.
- # in our case, we want to notify the category system that our path
+ # Called after the copy is finished to accomodate special cases.
+ # The op var is 0 for a copy, 1 for a move.
+ if op == 1:
+ # In our case, we want to notify the category system that our path
# changed, so that it updates related objects.
- if op == 1:
- old_url = getattr(self, '_v_category_url_before_move', None)
- if old_url is not None:
- self.activate(after_method_id='unindexObject').updateRelatedContent(
- old_url,
- self.getRelativeUrl())
-
+ old_url = getattr(self, '_v_category_url_before_move', None)
+ if old_url is not None:
+ self.activate(after_method_id='unindexObject').updateRelatedContent(
+ old_url,
+ self.getRelativeUrl())
+ elif op == 0:
+ # Paste a object.
+ # Update related subcontent
+ previous_path = self.getRelativeUrl().split('/')
+ previous_path[-1] = self._v_previous_id
+
+ self._updateInternalRelatedContent(local_self=self,
+ path=previous_path,
+ new_id=self.id)
#### Helper methods
More information about the Erp5-report
mailing list