1f0ae2712e9be8050b0b47f4c5d28c697161993b
1 ##parameters=items, **kw
2 ##title=Rename objects in a folder
4 from Products
.CMFDefault
.exceptions
import CopyError
5 from Products
.Plinn
.utils
import translate
6 _
= lambda msg
: translate(msg
, context
)
8 ids
, new_ids
= zip(*[(i
['id'], i
['new_id']) for i
in items
])
11 c
= context
.aq_explicit
12 for itemInfo
in items
:
13 item
= getattr(c
, itemInfo
['id'])
14 if item
.Title() != itemInfo
['title'] :
15 item
.setTitle(itemInfo
['title'])
19 if not ids
== new_ids
:
21 skiped
= context
.manage_renameObjects(ids
, new_ids
)
24 return context
.setStatus(True, _(u
'Item renamed.'))
26 return context
.setStatus(True, _(u
'Items renamed.'))
29 return context
.setStatus(True, _( u
'This item has not been renamed: "%s"') % ids
[0] )
31 return context
.setStatus(True
32 , _( u
'These items have not been renamed: %s') % \
33 ', '.join(['"%s"' % id for id in ids
]) )
35 return context
.setStatus(False, _(u
'Rename failed.'))
39 return context
.setStatus(False, _(u
'Nothing to change.'))
42 return context
.setStatus(True, _(u
'Item renamed.'))
44 return context
.setStatus(True, _(u
'Items renamed.'))