lint.
[Portfolio.git] / skins / remove_to_selection.py
1 ##parameters=ajax=''
2 from Products.CMFCore.utils import getToolByName
3
4 uidtool = getToolByName(context, 'portal_uidhandler')
5 utool = getToolByName(context, 'portal_url')
6 portal = utool.getPortalObject()
7 uid = uidtool.register(context)
8
9 sd = context.session_data_manager.getSessionData(create = 1)
10
11 selection = sd.get('objects_selection', [])
12 selDict = sd.get('objects_selection_dict', {})
13
14 lightboxpath = sd.get('lightboxpath', None)
15 selectionIsLightbox = False
16 if lightboxpath is None :
17 selection = sd.get('objects_selection', [])
18 else :
19 try :
20 lightbox = portal.restrictedTraverse(lightboxpath)
21 selection = lightbox.getUidList()
22 selectionIsLightbox = True
23 except KeyError :
24 sd.set('lightboxpath', None)
25 selection = sd.get('objects_selection', [])
26
27
28
29 if selDict.has_key(uid) :
30 del selDict[uid]
31 selection.remove(uid)
32 if selectionIsLightbox :
33 lightbox.remove(uid)
34 sd['objects_selection'] = selection
35 sd['objects_selection_dict'] = selDict
36
37 if not ajax:
38 return context.REQUEST.RESPONSE.redirect('%s/selection_view' % utool())