def __call__(self): if not self.status_id: return self container = PLONESOCIAL.microblog status = container.get(self.status_id) if not self.attachment_id: # do we want to be able to traverse to the status update itself? # Returning only the id for now return self.status_id attachments = IAttachmentStorage(status) attachment = attachments.get(self.attachment_id) if not self.preview_type: self.request.response.setHeader('content-type', attachment.getContentType()) self.request.response.setHeader( 'content-disposition', 'inline; ' 'filename="{0}"'.format(self.attachment_id.encode('utf8'))) return attachment if IDocconv is not None: docconv = IDocconv(attachment) if self.preview_type == 'thumb': if docconv.has_thumbs(): return self._prepare_imagedata(attachment, docconv.get_thumbs()[0]) elif self.preview_type == 'preview': if docconv.has_previews(): return self._prepare_imagedata(attachment, docconv.get_previews()[0]) raise NotFound
def attachments(self): """ Get preview image for content-related updates""" if self.is_preview_supported(): docconv = IDocconv(self.context.context) if docconv.has_thumbs(): return [ self.context.context.absolute_url() + '/docconv_image_thumb.jpg' ]
def attachments(self): """ Get preview images for status update attachments """ if all([ self.is_attachment_supported(), self.is_preview_supported(), IAttachmentStoragable.providedBy(self.status), ]): storage = IAttachmentStorage(self.status) attachments = storage.values() for attachment in attachments: docconv = IDocconv(attachment) if docconv.has_thumbs(): url = api.portal.get().absolute_url() yield ('{portal_url}/@@status-attachments/{status_id}/' '{attachment_id}/thumb').format( portal_url=url, status_id=self.status.getId(), attachment_id=attachment.getId())