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 size(self): a = ISized(self.context, None) if a is None: raise AttributeError('size') return a.sizeForDisplay()
def size(self): sized = ISized(self.context) return sized.sizeForDisplay()
def format(self, value): sz = ISized(value, None) if sz is None: return value return sz.sizeForDisplay()