Champs client++
[Plinn.git] / skins / custom_control / folder_up_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 subset_ids = [ obj.getId() for obj in context.listFolderContents() ]
10 try:
11 try:
12 attempt = context.moveObjectsUp(ids, delta, subset_ids=subset_ids)
13 except TypeError:
14 # Zope 2.7.0
15 attempt = context.moveObjectsUp(ids, delta)
16 if attempt:
17 msg = _(attempt == 1 and \
18 '%d item moved up.' or \
19 '%d items moved up.')().encode('utf-8') % attempt
20 return context.setStatus( True, msg)
21 else:
22 return context.setStatus(False, 'Nothing to change.')
23 except ValueError, errmsg:
24 return context.setStatus(False, 'ValueError: %s' % errmsg)