2 from Products
.CMFCore
.utils
import getToolByName
3 from Products
.Portfolio
.utils
import translate
4 def _(message
) : return translate(message
, context
).encode('utf-8')
6 uidtool
= getToolByName(context
, 'portal_uidhandler')
7 utool
= getToolByName(context
, 'portal_url')
8 portal
= utool
.getPortalObject()
9 uid
= uidtool
.register(context
)
11 sd
= context
.session_data_manager
.getSessionData(create
= 1)
13 selection
= sd
.get('objects_selection', [])
14 selDict
= sd
.get('objects_selection_dict', {})
16 lightboxpath
= sd
.get('lightboxpath', None)
17 selectionIsLightbox
= False
18 if lightboxpath
is None :
19 selection
= sd
.get('objects_selection', [])
22 lightbox
= portal
.restrictedTraverse(lightboxpath
)
23 selection
= lightbox
.getUidList()
24 selectionIsLightbox
= True
26 sd
.set('lightboxpath', None)
27 selection
= sd
.get('objects_selection', [])
30 if not selDict
.has_key(uid
) :
33 if selectionIsLightbox
:
35 sd
['objects_selection'] = selection
36 sd
['objects_selection_dict'] = selDict
37 msg
= _('%s added to selection.') % context
.getPortalTypeName()
39 msg
= _("This %s is already in the selection.") % context
.getPortalTypeName()
42 context
.setStatus(True, msg
)
43 return context
.setRedirect(context
, 'object/view')