2463656ff683d5a7696cf802d4d43b0720f39393
1 ##parameters=load='',unload='',**kw
2 from Products
.CMFCore
.utils
import getToolByName
3 from Products
.Plinn
.PloneMisc
import Batch
6 lightboxSelected
= False
8 utool
= getToolByName(context
, 'portal_url')
9 portal
= utool
.getPortalObject()
10 portalDepth
= len(portal
.getPhysicalPath())
11 uidh
= getToolByName(context
, 'portal_uidhandler')
12 pptool
= getToolByName(context
, 'portal_photo_print', None)
14 sd
= context
.session_data_manager
.getSessionData(create
= 1)
15 path
= context
.getPhysicalPath()
18 sd
.set('lightboxpath', path
)
19 selection
= context
.getUidList()
20 sd
.set('objects_selection', selection
)
21 sd
.set('objects_selection_dict', dict([(uid
, True) for uid
in selection
]))
23 sd
.set('lightboxpath', None)
24 sd
.set('objects_selection', [])
25 sd
.set('objects_selection_dict', {})
27 sessionpath
= sd
.get('lightboxpath', None)
28 if sessionpath
== path
:
29 lightboxSelected
= True
30 buttons
.append({'name': 'unload', 'value': 'Unload from my selection'})
32 buttons
.append({'name':'load', 'value': 'Load in my selection'})
34 start
= req
.get('b_start', 0)
35 brains
= [uidh
.getBrain(uid
) for uid
in context
.uids
]
36 batch
= Batch(brains
, context
.default_batch_size
, start
, orphan
=1, quantumleap
=1)
38 hereUrl
= context
.absolute_url()
39 cart
= sd
.get('cart', None)
42 for index
, b
in enumerate(batch
) :
43 path
= '/'.join(b
.getPath().split('/')[portalDepth
:])
46 buyable
= bool(pptool
.getPrintingOptionsFor(p
))
47 if cart
and cart
.locked
:
52 d
= {'href' : '%s/lightboxcontext/%s' % (hereUrl
, path
)
53 ,'thumbUrl' : '%s/getThumbnail' % b
.getURL()
54 ,'thumbSize' : b
.getThumbnailSize
55 ,'title' : ('%s - %s' % (b
.Title
, b
.Description
)).strip(' -')
64 features
['del'] = lambda b
: '%s/remove_to_lightbox?uid=%s' % (hereUrl
, b
.cmf_uid
)
65 features
['cart'] = lambda b
: '%s/get_slide_buyable_items' % b
.getURL()
67 options
['infos'] = infos
68 options
['batch'] = batch
69 options
['features'] = features
70 options
['buttons'] = buttons
71 options
['lightboxSelected'] = lightboxSelected
72 options
['container_type'] = 'lightbox'
74 return context
.lightbox_view_template(**options
)