Renommage des éléments avec édition des titres et des ids en une seule opération.
[Plinn.git] / skins / custom_control / folder_down_control.py
1 ##parameters=ids, delta, **kw
2 ##
3
4 #TODO : translate messages
5 #from Products.PlacelessTranslationService.MessageID import MessageIDFactory
6 #_ = MessageIDFactory('default', as_unicode=True)
7 _ = lambda x : lambda : x
8
9
10 subset_ids = [ obj.getId() for obj in context.listFolderContents() ]
11 try:
12 try:
13 attempt = context.moveObjectsDown(ids, delta, subset_ids=subset_ids)
14 except TypeError:
15 # Zope 2.7.0
16 attempt = context.moveObjectsDown(ids, delta)
17 if attempt:
18 msg = _(attempt == 1 and \
19 '%d item moved down.' or \
20 '%d items moved down.')().encode('utf-8') % attempt
21 return context.setStatus( True, msg)
22 else:
23 return context.setStatus(False, 'Nothing to change.')
24 except ValueError, errmsg:
25 return context.setStatus(False, 'ValueError: %s' % errmsg)