f5afc8c9f3f5915d5a26ee05cf215870cef7a3e0
1 ##parameters=lightbox, pho_start=None, batch_size=None
2 from Products
.CMFCore
.utils
import getToolByName
3 from Products
.Plinn
.PloneMisc
import Batch
5 utool
= getToolByName(context
, 'portal_url')
6 portal
= utool
.getPortalObject()
7 portalDepth
= len(portal
.getPhysicalPath())
8 uidh
= getToolByName(context
, 'portal_uidhandler')
9 pptool
= getToolByName(context
, 'portal_photo_print', None)
11 sd
= context
.session_data_manager
.getSessionData(create
= 1)
12 path
= context
.getPhysicalPath()
14 start
= pho_start
if pho_start
is not None else 0
15 brains
= [uidh
.getBrain(uid
) for uid
in context
.uids
]
16 batch_size
= batch_size
if batch_size
is not None else context
.default_batch_size
17 batch
= Batch(brains
, batch_size
, start
, quantumleap
=1)
19 lightboxUrl
= lightbox
.absolute_url()
20 cart
= sd
.get('cart', None)
23 for index
, b
in enumerate(batch
) :
24 path
= '/'.join(b
.getPath().split('/')[portalDepth
:])
27 buyable
= bool(pptool
.getPrintingOptionsFor(p
))
28 if cart
and cart
.locked
:
33 d
= {'href' : '%s/lightboxcontext/%s' % (lightboxUrl
, path
)
34 ,'thumbUrl' : '%s/getThumbnail' % b
.getURL()
35 ,'thumbSize' : b
.getThumbnailSize
36 ,'title' : ('%s - %s' % (b
.Title
, b
.Description
)).strip(' -')
45 features
['del'] = lambda b
: '%s/remove_to_lightbox?uid=%s' % (lightboxUrl
, b
.cmf_uid
)
46 features
['cart'] = lambda b
: '%s/get_slide_buyable_items' % b
.getURL()
48 return {'infos' : infos
,
50 'features' : features
}