Commit 04cd0e45 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add an optional parameter dry_run. Acquire portal_categories. Use setTitle. Return a better report.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1347 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a5565885
import string import string
def fixMissingCategoryTitles(self): def fixMissingCategoryTitles(self, dry_run=0):
""" """
Recursively sets a default title when it's empty or equal to id Recursively sets a default title when it's empty or equal to id
Must be called on CategoryTool Must be called on CategoryTool
""" """
for base in self.getChildNodes(): msg = ''
objectlist = base.getCategoryChildValueList() for base in self.portal_categories.getChildNodes():
for object in objectlist : object_list = base.getCategoryChildValueList()
for object in object_list :
title = object.getTitle() title = object.getTitle()
id = object.getId() id = object.getId()
if len(title) == 0 or title is None or title == id : if not title:
new_title = string.capwords(id.replace('_', ' ')) new_title = string.capwords(id.replace('_', ' '))
setattr(object, 'title', new_title) if not dry_run:
return 'done' object.setTitle(new_title)
msg += 'The title of %s was set to %s\n' % (object.getRelativeUrl(), new_title)
return msg
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