Optimisation
[Portfolio.git] / skins / selectioncontext.py
index 36727f6..fa7c090 100644 (file)
@@ -2,7 +2,6 @@
 from Products.CMFCore.utils import getToolByName
 from Products.Portfolio.utils import translate
 def _(message) : return translate(message, context).encode('utf-8')
-bsize = 20
 options = {}
 
 uidh = getToolByName(context, 'portal_uidhandler')
@@ -16,6 +15,7 @@ portalDepth = len(portal.getPhysicalPath())
 req = context.REQUEST
 toUrl = req.physicalPathToURL
 resp = req.RESPONSE
+bsize = portal.getProperty('default_batch_size', 20)
 
 if traverse_subpath[-1] == 'photo_view_ajax' :
     photoSubPath = traverse_subpath[:-1]
@@ -60,7 +60,8 @@ if ajax == True :
     photoPath = list(photo.getPhysicalPath())
     photoPath.insert(portalDepth, 'selectioncontext')
     options['lastBcUrl'] = toUrl(photoPath)
-    meth = getattr(photo, 'photo_view_ajax_template')
+    app = context.restrictedTraverse('/')
+    meth = app.restrictedTraverse(photo.getPhysicalPath() + ('photo_view_ajax_template',))
     return meth(req, resp, **options)
 
 
@@ -81,8 +82,9 @@ for i, uid in enumerate(selection) :
     d = {'src': '%s/getThumbnail' % b.getURL()
         ,'href': toUrl(path)
         ,'thumbSize': size
-        ,'title' : b.Title
-        ,'className': className
+        ,'title' : b.Description
+        ,'className' : className
+        ,'displayed' : uid == photouid
         , 'index': i
         }
     infos.append(d)
@@ -134,5 +136,6 @@ options['breadcrumbs'] = breadcrumbs
 
 ti = photo.getTypeInfo()
 method_id = ti.queryMethodID('view', context=photo)
-meth = getattr(photo, method_id)
+app = context.restrictedTraverse('/')
+meth = app.restrictedTraverse(photo.getPhysicalPath() + (method_id,))
 return meth(req, resp, **options)