Back to index

plone3  3.1.7
getBatchItemInfos.py
Go to the documentation of this file.
00001 ## Script (Python) "getBatchItemInfos"
00002 ##parameters=batch_obj
00003 ##title=
00004 ##
00005 from Products.CMFCore.utils import getToolByName
00006 
00007 utool = getToolByName(script, 'portal_url')
00008 portal_url = utool()
00009 
00010 items = []
00011 
00012 for item in batch_obj:
00013     item_description = item.Description()
00014     item_icon = item.getIcon(1)
00015     item_title = item.Title()
00016     item_type = remote_type = item.Type()
00017     if item_type == 'Favorite' and not item_icon == 'p_/broken':
00018         item = item.getObject()
00019         item_description = item_description or item.Description()
00020         item_title = item_title or item.Title()
00021         remote_type = item.Type()
00022     is_file = remote_type in ('File', 'Image')
00023     is_link = remote_type == 'Link'
00024     items.append( { 'description': item_description,
00025                     'format': is_file and item.Format() or '',
00026                     'icon': item_icon and
00027                             ( '%s/%s' % (portal_url, item_icon) ) or '',
00028                     'size': is_file and
00029                             '%0.0f kb' % ( item.get_size() / 1024.0 ) or '',
00030                     'title': item_title,
00031                     'type': item_type,
00032                     'url': is_link and item.getRemoteUrl() or
00033                             item.absolute_url() } )
00034 
00035 return tuple(items)