2 from ZTUtils
import make_query
as mq
3 from Products
.CMFCore
.utils
import getToolByName
4 pptool
= getToolByName(context
, 'portal_photo_print', None)
5 uidtool
= getToolByName(context
, 'portal_uidhandler')
6 form
= context
.REQUEST
.form
7 portfolio
= context
.getParentNode()
8 bsize
= form
.get('b_size',20)
12 sd
= context
.session_data_manager
.getSessionData(create
= 1)
13 selDict
= sd
.get('objects_selection_dict', {})
14 cart
= sd
.get('cart', None)
16 contextUid
= getattr(context
, 'cmf_uid', None)
17 if contextUid
is not None :
18 contextUid
= contextUid()
20 uidh
= getToolByName(context
, 'portal_uidhandler')
21 contextUid
= uidtool
.register(context
)
22 isSelected
= selDict
.has_key(contextUid
)
24 for i
, p
in enumerate(portfolio
.listNearestFolderContents(contentFilter
={'portal_type' : ['Photo']}, sorted=True)) :
27 uid
= getattr(p
, 'cmf_uid', None)
30 selected
= selDict
.has_key(uid
)
31 size
= p
.getThumbnailSize()
32 size
= {'width':int(size
['width']/2.0), 'height':int(size
['height']/2.0)}
33 purl
= p
.absolute_url()
34 d
= {'src': '%s/getThumbnail' % purl
38 ,'className': (selected
and 'selected' or '') + ((p
== context
) and ' displayed' or '')
47 buyable
= bool(pptool
.getPrintingOptionsFor(context
))
48 if cart
and cart
.locked
:
54 previous
= infos
[index
- 1]['href']
58 if index
< len(infos
) -1 :
59 next
= infos
[index
+ 1]['href']
63 return {'infos' : infos
,
64 'isSelected' : isSelected
,
66 'backUrl' : '%s?%s' % (portfolio
.absolute_url(), mq(pho_start
= index
/bsize
*bsize
)),
68 'previous' : previous
,
70 'reBaseCtxUrl':'null',
71 'canonicalUrl':'null'}