Commit bbb7882a authored by Vincent Pelletier's avatar Vincent Pelletier

Fix coding style of my own early code.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12565 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5950fd38
...@@ -81,31 +81,43 @@ class CopyContainer: ...@@ -81,31 +81,43 @@ class CopyContainer:
return self.manage_main(self, REQUEST) return self.manage_main(self, REQUEST)
return cp return cp
def _updateInternalRelatedContent(self, local_self, path, new_id): def _updateInternalRelatedContent(self, object, path_item_list, new_id):
""" """
Search for categories starting with path in local_self and its Search for categories starting with path_item_list in object and its
subobjects, and replaces the last common item in category paths subobjects, and replace the last item of path_item_list by new_id
by new_id. in matching category path.
object
Object to recursively check in.
path_item_list
Path to search for.
Should correspond to path_item_list when the function is initially
called - but remains identical among all recursion levels under the
same call.
new_id
Id replacing the last item in path_item_list.
Example : Example :
category : "a/b/c/d/e" previous category value : 'a/b/c/d/e'
path : "a/b/c" path_item_list : ['a', 'b', 'c']
new_id : "z" new_id : 'z'
result : "a/b/z/d/e" final category value : 'a/b/z/d/e'
""" """
# if getattr(self,'_v_is_renamed',0): for subobject in object.objectValues():
for object in local_self.objectValues(): self._updateInternalRelatedContent(object=subobject,
self._updateInternalRelatedContent(local_self=object, path=path, new_id=new_id) path_item_list=path_item_list,
changed=0 new_id=new_id)
categories=local_self.getCategoryList() changed = 0
for pos in range(len(categories)): category_list = object.getCategoryList()
catname=categories[pos].split("/") path_len = len(path_item_list)
if catname[1:len(path)+1]==path: # XXX Should be possible to do this in a cleaner way for position in xrange(len(category_list)):
catname[len(path)]=new_id category_name = category_list[position].split('/')
categories[pos]="/".join(catname) if category_name[1:path_len + 1] == path_item_list: # XXX Should be possible to do this in a cleaner way
changed=1 category_name[path_len] = new_id
if changed: category_list[position] = '/'.join(category_name)
local_self.setCategoryList(categories) changed = 1
if changed != 0:
object.setCategoryList(category_list)
def _recursiveSetActivityAfterTag(self,object): def _recursiveSetActivityAfterTag(self,object):
""" """
...@@ -140,8 +152,8 @@ class CopyContainer: ...@@ -140,8 +152,8 @@ class CopyContainer:
# Search for categories that have to be updated in sub objects. # Search for categories that have to be updated in sub objects.
self._recursiveSetActivityAfterTag(ob) self._recursiveSetActivityAfterTag(ob)
self._updateInternalRelatedContent(local_self=ob, self._updateInternalRelatedContent(object=ob,
path=ob.getRelativeUrl().split("/"), path_item_list=ob.getRelativeUrl().split("/"),
new_id=new_id) new_id=new_id)
#ob._v_is_renamed = 1 #ob._v_is_renamed = 1
# Rename the object # Rename the 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