1 ##parameters=pho_start=None, batch_size=None
2 from Products
.CMFCore
.utils
import getToolByName
3 from Products
.Plinn
.PloneMisc
import Batch
5 uidh
= getToolByName(context
, 'portal_uidhandler')
6 utool
= getToolByName(context
, 'portal_url')
7 pptool
= getToolByName(context
, 'portal_photo_print', None)
8 portal
= utool
.getPortalObject()
10 portalDepth
= len(portal
.getPhysicalPath())
12 toUrl
= req
.physicalPathToURL
14 # check if a lightbox is currently selected
15 lightboxpath
= req
.SESSION
.get('lightboxpath', None)
16 selectionIsLightbox
= False
17 if lightboxpath
is None :
18 selection
= req
.SESSION
.get('objects_selection', [])
21 lightbox
= portal
.restrictedTraverse(lightboxpath
)
22 selection
= lightbox
.getUidList()
23 selectionIsLightbox
= True
25 req
.SESSION
.set('lightboxpath', None)
26 selection
= req
.SESSION
.get('objects_selection', [])
29 brains
= [uidh
.getBrain(uid
) for uid
in selection
]
30 start
= pho_start
if pho_start
is not None else 0
31 batch_size
= batch_size
if batch_size
is not None else context
.default_batch_size
32 batch
= Batch(brains
, batch_size
, start
, quantumleap
=1)
33 cart
= req
.SESSION
.get('cart', None)
36 for index
, b
in enumerate(batch
) :
37 path
= b
.getPath().split('/')
38 path
.insert(portalDepth
, 'selectioncontext')
41 buyable
= bool(pptool
.getPrintingOptionsFor(p
))
42 if cart
and cart
.locked
:
47 d
= {'href': toUrl('/'.join(path
))
48 ,'thumbUrl' : '%s/getThumbnail' % b
.getURL()
49 ,'thumbSize' : b
.getThumbnailSize
50 ,'title' : ('%s - %s' % (b
.Title
, b
.Description
)).strip(' -')
59 features
['checkbox'] = True
60 features
['cart'] = lambda b
: '%s/get_slide_buyable_items' % b
.getURL()
62 return {'infos' : infos
,
64 'features' : features
}