Back to index

plone3  3.1.7
atctListAlbum.py
Go to the documentation of this file.
00001 ## Script (Python) "atctListAlbum"
00002 ##title=Helper method for photo album view
00003 ##bind container=container
00004 ##bind context=context
00005 ##bind namespace=
00006 ##bind script=script
00007 ##bind subpath=traverse_subpath
00008 ##parameters=images=0, folders=0, subimages=0, others=0
00009 
00010 from Products.CMFPlone.utils import base_hasattr
00011 
00012 result = {}
00013 
00014 if context.portal_type == 'Topic':
00015     queryMethod = context.queryCatalog
00016 else:
00017     queryMethod = context.getFolderContents
00018 
00019 if images:
00020     result['images'] = queryMethod({'portal_type':('Image',)},full_objects=True)
00021 if folders:
00022     # We don't need the full objects for the folders
00023     result['folders'] = queryMethod({'portal_type':('Folder',)})
00024 if subimages:
00025     #Handle brains or objects
00026     if base_hasattr(context, 'getPath'):
00027         path = context.getPath()
00028     else:
00029         path = '/'.join(context.getPhysicalPath())
00030     # Explicitly set path to remove default depth
00031     result['subimages'] = queryMethod({'Type':('Image',), 'path':path})
00032 if others:
00033     searchContentTypes = context.plone_utils.getUserFriendlyTypes()
00034     filtered = [p_type for p_type in searchContentTypes
00035                 if p_type not in ('Image', 'Folder',) ]
00036     if filtered:
00037         # We don't need the full objects for the folder_listing
00038         result['others'] = queryMethod({'portal_type':filtered})
00039     else:
00040         result['others'] = ()
00041 
00042 return result