1 ##parameters=pho_start=None, batch_size=None
2 from Products
.CMFCore
.utils
import getToolByName
3 from Products
.Plinn
.PloneMisc
import Batch
4 from Products
.Portfolio
.utils
import translate
5 def _(message
) : return translate(message
, context
).encode('utf-8')
7 uidh
= getToolByName(context
, 'portal_uidhandler')
8 utool
= getToolByName(context
, 'portal_url')
9 pptool
= getToolByName(context
, 'portal_photo_print', None)
10 portal
= utool
.getPortalObject()
12 portalDepth
= len(portal
.getPhysicalPath())
14 toUrl
= req
.physicalPathToURL
16 # check if a lightbox is currently selected
17 lightboxpath
= req
.SESSION
.get('lightboxpath', None)
18 selectionIsLightbox
= False
19 if lightboxpath
is None :
20 selection
= req
.SESSION
.get('objects_selection', [])
23 lightbox
= portal
.restrictedTraverse(lightboxpath
)
24 selection
= lightbox
.getUidList()
25 selectionIsLightbox
= True
27 req
.SESSION
.set('lightboxpath', None)
28 selection
= req
.SESSION
.get('objects_selection', [])
31 start
= pho_start
if pho_start
is not None else 0
32 brains
= [uidh
.getBrain(uid
) for uid
in selection
]
33 batch
= Batch(brains
, batch_size
, start
, quantumleap
=1)
34 cart
= req
.SESSION
.get('cart', None)
37 for index
, b
in enumerate(batch
) :
38 path
= b
.getPath().split('/')
39 path
.insert(portalDepth
, 'selectioncontext')
42 buyable
= bool(pptool
.getPrintingOptionsFor(p
))
43 if cart
and cart
.locked
:
48 d
= {'href': toUrl('/'.join(path
))
49 ,'thumbUrl' : '%s/getThumbnail' % b
.getURL()
50 ,'thumbSize' : b
.getThumbnailSize
51 ,'title' : ('%s - %s' % (b
.Title
, b
.Description
)).strip(' -')
60 features
['del'] = lambda b
: '%s/remove_to_selection' % b
.getURL()
61 features
['cart'] = lambda b
: '%s/get_slide_buyable_items' % b
.getURL()
63 return {'infos' : infos
,
65 'features' : features
}