X-Git-Url: https://svn.cri.ensmp.fr/git/Portfolio.git/blobdiff_plain/b14b0bd922e6ebf247d8ead6e8a27bc9730b02a6..5b7fe372434690e2dc2f1f72b78181986614f3e3:/photo.py?ds=sidebyside diff --git a/photo.py b/photo.py index a90ef42..f0a76f5 100755 --- a/photo.py +++ b/photo.py @@ -21,17 +21,15 @@ from Products.CMFCore.permissions import View, AccessContentsInformation, \ from permissions import ViewRawImage from zope.component.factory import Factory from zope.interface import implements -#from webdav.WriteLockInterface import WriteLockInterface as z2IWriteLock from webdav.interfaces import IWriteLock from Products.CMFCore.interfaces import IContentish from Products.CMFCore.interfaces import IDynamicType -#from Products.CMFCore.interfaces.Contentish import Contentish as z2IContentish from Products.CMFCore.DynamicType import DynamicType from Products.CMFCore.CMFCatalogAware import CMFCatalogAware from Products.Photo.Photo import Photo as BasePhoto from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl -from Products.CMFCore.utils import getToolByName +from Products.CMFCore.utils import getToolByName, getUtilityByInterfaceName from Products.Photo.cache import memoizedmethod from Products.DCWorkflow.utils import modifyRolesForPermission from interfaces import IPhoto @@ -40,7 +38,6 @@ class Photo(DynamicType, CMFCatalogAware, BasePhoto, DefaultDublinCoreImpl) : """ Photo CMF aware """ implements(IPhoto, IContentish, IWriteLock, IDynamicType) - #__implements__ = (z2IContentish, IWriteLock, DynamicType.__implements__) meta_type = BasePhoto.meta_type manage_options = BasePhoto.manage_options @@ -50,6 +47,7 @@ class Photo(DynamicType, CMFCatalogAware, BasePhoto, DefaultDublinCoreImpl) : security.declareProtected(ViewRawImage, 'getJpegImage') def __init__(self, id, title='', file='', content_type='', precondition='', **kw) : + DefaultDublinCoreImpl.__init__(self, title=title) BasePhoto.__init__(self, id, title, file, content_type=content_type, precondition=precondition, **kw) self.id = id self.title = title @@ -60,7 +58,10 @@ class Photo(DynamicType, CMFCatalogAware, BasePhoto, DefaultDublinCoreImpl) : def update_data(self, data, content_type=None) : BasePhoto.update_data(self, data, content_type=content_type) - self.reindexObject() + # update_data can be invoked during construction + # in this case, reindexObject put a parasite catalag entry. + if self.getParentNode() : + self.reindexObject() def _getAfterResizingHooks(self) : @@ -152,7 +153,7 @@ class Photo(DynamicType, CMFCatalogAware, BasePhoto, DefaultDublinCoreImpl) : @memoizedmethod() def DateTimeOriginal(self) : """ return DateTimeOriginal exif tag value or created """ - dto = self.getXmpValue('exif:DateTimeOriginal') + dto = self.getXmpValue('exif:DateTimeOriginal') or self.getXmpValue('xmp:CreateDate') if dto : return DateTime(dto) else : @@ -192,14 +193,6 @@ class Photo(DynamicType, CMFCatalogAware, BasePhoto, DefaultDublinCoreImpl) : return getattr(self, '_hiddenForAnon', False) -# security.declareProtected(AccessContentsInformation, 'position') -# def position(self): -# " returns position of self in parent container " -# parent = self.getParentNode() -# position = parent.getObjectPosition(self.getId()) -# return position - - # # SimpleItem interface # @@ -221,4 +214,14 @@ class Photo(DynamicType, CMFCatalogAware, BasePhoto, DefaultDublinCoreImpl) : InitializeClass(Photo) -PhotoFactory = Factory(Photo) \ No newline at end of file +class _PhotoFactory(Factory) : + def __call__(self, *args, **kw): + if not kw.has_key('thumb_height') or not kw.has_key('thumb_width') : + utool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IURLTool') + portal = utool.getPortalObject() + size = portal.getProperty('thumb_size') + kw.update({'thumb_height' : size, 'thumb_width' : size }) + return self._callable(*args, **kw) + + +PhotoFactory = _PhotoFactory(Photo) \ No newline at end of file