def getAttachments(self): context = self.context request = self.request extension = IAttachmentsExtension(context) ids = getUtility(IIntIds) url = '%s/@@content.attachment'%absoluteURL(getSite(), request) attachments = [] for name in self.model.attachments: attach = extension.get(name) aurl = '%s/%s'%(url, ids.getId(attach)) size = ISized(attach) if size.sizeForSorting()[0] is not None: size = size.sizeForDisplay() else: size = '' attachments.append( {'name': name, 'title': attach.title or name, 'description': attach.description, 'url': aurl, 'size': size, 'icon': queryMultiAdapter((attach, request), name='zmi_icon')}) return attachments
def getAttachments(self): context = self.context request = self.request extension = IAttachmentsExtension(context) ids = getUtility(IIntIds) url = "%s/@@content.attachment" % absoluteURL(getSite(), self.request) attachments = [] for aId in self.model.attachments: attach = extension.get(aId) aurl = "%s/content.attachments/%s" % (url, ids.getId(attach)) size = ISized(attach) if size.sizeForSorting()[0] is not None: size = size.sizeForDisplay() else: size = "" attachments.append( { "name": aId, "title": attach.title or aId, "description": attach.description, "url": aurl, "size": size, "icon": queryMultiAdapter((attach, request), name="zmi_icon"), } ) return attachments
def getImages(self): context = self.context extension = IAttachmentsExtension(context) ids = getUtility(IIntIds) url = '%s/@@content.attachment'%absoluteURL(getSite(), self.request) for imageId in self.model.images: image = extension.get(imageId) if IImage.providedBy(image) and image: img_url = '%s/%s'%(url, ids.getId(removeAllProxies(image))) preview = image.preview.generatePreview(100, 100) yield {'name': image.__name__, 'title': image.title or image.__name__, 'url': img_url, 'purl': '%s/preview/100x100'%img_url}
def getImage(self): context = self.context extension = IAttachmentsExtension(context) image = extension.get(self.__parent__.model.primaryImage) if IImage.providedBy(image) and image: preview = image.preview.generatePreview(100, 100) url = "%s/@@content.attachment/%s" % ( absoluteURL(getSite(), self.request), getUtility(IIntIds).queryId(image), ) return { "name": image.__name__, "title": image.title or image.__name__, "url": url, "purl": "%s/preview/100x100" % url, }
def CopyAttachments(object, obevent): request = getRequest() if request is None: return if IContentEditorPreference(request.principal).editor != 'extjs': return data = obevent.data if data.format != 'zope.source.html': return ids = getUtility(IIntIds) if ids.queryId(object) is None: return res = splitText.split(data.text) if len(res) <= 1: return extension = IAttachmentsExtension(object) for idx in range(1, len(res)-1, 2): try: content = ids.queryObject(int(res[idx][26:-1])) if content is None: continue except: continue if content is \ removeAllProxies(extension.get(content.__name__)): continue copier = IObjectCopier(content) newName = copier.copyTo(extension) newContent = extension[newName] res[idx] = '%s%s"'%(res[idx][:26], ids.queryId(newContent)) data.text = u''.join(res)
def getImages(self): context = self.context extension = IAttachmentsExtension(context) url = absoluteURL(context, self.request) ids = getUtility(IIntIds) url = "%s/@@content.attachment" % absoluteURL(getSite(), self.request) for imageId in self.model.additionalImages: image = extension.get(imageId) if IImage.providedBy(image) and image: preview = image.preview.generatePreview(100, 100) img_url = "%s/%s" % (url, ids.getId(image)) yield { "name": imageId, "title": image.title or imageId, "url": img_url, "purl": "%s/preview/100x100" % img_url, }