Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
 def size(self):
     a = ISized(self.context, None)
     if a is None:
         raise AttributeError('size')
     return a.sizeForDisplay()
Exemplo n.º 4
0
 def size(self):
     sized = ISized(self.context)
     return sized.sizeForDisplay()
Exemplo n.º 5
0
 def size(self):
     sized = ISized(self.context)
     return sized.sizeForDisplay()
Exemplo n.º 6
0
 def format(self, value):
     sz = ISized(value, None)
     if sz is None:
         return value
     return sz.sizeForDisplay()
Exemplo n.º 7
0
 def size(self):
     a = ISized(self.context, None)
     if a is None:
         raise AttributeError('size')
     return a.sizeForDisplay()