Back to index

plone3  3.1.7
image.py
Go to the documentation of this file.
00001 from Products.Archetypes.atapi import DisplayList
00002 from Products.ATContentTypes.interface.image import IPhotoAlbum
00003 from Products.ATContentTypes.interface.dataExtractor import IDataExtractor
00004 from Products.ATContentTypes.interface.folder import IFilterFolder
00005 
00006 from zope.interface import implements
00007 
00008 
00009 class PhotoDataExtractor(object):
00010     """
00011     """
00012     implements(IDataExtractor)
00013     def __init__(self, context):
00014         self.context = context
00015 
00016     def getData(self, format=None,width=None,height=None,**kwargs):
00017         if format:
00018             ### changeFormat
00019             pass
00020         if width or height:
00021             ### changeSize
00022             pass
00023         return None
00024 
00025 class PhotoAlbumFilter(object):
00026     """
00027     """
00028     implements(IFilterFolder)
00029 
00030     def __init__(self, context):
00031         self.context = context
00032 
00033     def listObjects(self):
00034         return [item for item in self.context.ObjectValues(['Image','PhotoAlbum'])]
00035 
00036 class PhotoAlbum(object):
00037     """
00038     interface that adapts a folder into a photo album
00039     """
00040     implements(IPhotoAlbum)
00041 
00042     def __init__(self, context):
00043         self.context = context
00044 
00045     def setSymbolicPhoto(self,photo=None):
00046         """
00047         set the photo which represents the album
00048         """
00049         pass
00050 
00051     def getSymbolicPhoto():
00052         """
00053         get the photo which represents the album
00054         """
00055         pass
00056 
00057     def getDisplayPhotosList(self):
00058         """
00059         return a display list for symbolic_photo field
00060         """
00061         brains = self.getFolderContents(contentFilter={'meta_type':['ATPhoto']})
00062         photos_list = [(b.getObject().UID(), str(b.Title or b.getId)[:70]) for b in brains]
00063         return DisplayList( [('','<no reference>')] + photos_list )
00064