Example #1
0
 def actions(self):
     """
     gives us the action dict of the object
     """
     try:
         objId = getUtility(IIntIds).getId(self.context)
     except KeyError:
         objId = 1000
     retList = []
     adapSize = ISized(self.context)
     # adapSize.sizeForSorting() returns ('item', n)
     if checkPermission('org.ict_ok.components.host.Add', self.context) and \
        (adapSize.sizeForSorting()[1] < 1):
         tmpDict = {}
         tmpDict['oid'] = u"c%sstart_scanner" % objId
         tmpDict['title'] = _(u"start scanner")
         tmpDict['href'] = u"%s/@@start_scanner.html" % \
                zapi.absoluteURL(self.context, self.request)
         tmpDict['tooltip'] = _(u"starts the network scanner (as user:%s)"\
                                % self.request.principal.title)
         retList.append(tmpDict)
     #tmpDict = {}
     #tmpDict['oid'] = u"a%s" % objId
     #tmpDict['title'] = u"ich bin ein Titel"
     #tmpDict['href'] = u"http://www.essen.de"
     #tmpDict['tooltip'] = u"ich bin der \"aa\" 'bb' dazugehörige T"
     #retList.append(tmpDict)
     return retList
    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
Example #4
0
def get_size(self):
    size = ISized(self, None)
    if size is not None:
	unit, amount = size.sizeForSorting()
	if unit == 'byte':
	    return amount
    method = getattr(self, '__five_original_get_size', None)
    if method is not None:
        return self.__five_original_get_size()
Example #5
0
 def get_size(self):
     # Get the size of the content item in bytes.
     #
     # Used both in folder listings and in DAV PROPFIND requests.
     #
     # The default implementation delegates to an ISized adapter and calls
     # getSizeForSorting(). This returns a tuple (unit, value). If the unit
     # is 'bytes', the value is returned, otherwise the size is 0.
     sized = ISized(self, None)
     if sized is None:
         return 0
     unit, size = sized.sizeForSorting()
     if unit == 'bytes':
         return size
     return 0
    def get_size(self):
        """Get the size of the content item in bytes. Used both in folder
        listings and in DAV PROPFIND requests.

        The default implementation delegates to an ISized adapter and calls
        getSizeForSorting(). This returns a tuple (unit, value). If the unit
        is 'bytes', the value is returned, otherwise the size is 0.
        """
        sized = ISized(self, None)
        if sized is None:
            return 0
        unit, size = sized.sizeForSorting()
        if unit == 'bytes':
            return size
        return 0
Example #7
0
 def actions(self):
     """
     gives us the action dict of the object
     """
     try:
         objId = getUtility(IIntIds).getId(self.context)
     except:
         objId = 1000
     retList = []
     if appsetup.getConfigContext().hasFeature('devmode') and \
        checkPermission('org.ict_ok.components.host.Edit', self.context):
         quoter = URLQuote(self.request.getURL())
         tmpDict = {}
         tmpDict['oid'] = u"c%strigger_online" % objId
         tmpDict['title'] = _(u"Trigger online")
         tmpDict['href'] = u"%s/@@trigger_online?nextURL=%s" % \
                (zapi.absoluteURL(self.context, self.request),
                 quoter.quote())
         retList.append(tmpDict)
         tmpDict = {}
         tmpDict['oid'] = u"c%strigger_offline" % objId
         tmpDict['title'] = _(u"Trigger offline")
         tmpDict['href'] = u"%s/@@trigger_offline?nextURL=%s" % \
                (zapi.absoluteURL(self.context, self.request),
                 quoter.quote())
         retList.append(tmpDict)
         tmpDict = {}
         tmpDict['oid'] = u"c%strigger_not1" % objId
         tmpDict['title'] = _(u"Trigger notification1")
         tmpDict['href'] = u"%s/@@trigger_not1?nextURL=%s" % \
                (zapi.absoluteURL(self.context, self.request),
                 quoter.quote())
         retList.append(tmpDict)
     adapSize = ISized(self.context)
     if checkPermission('org.ict_ok.components.interface.Add', self.context) and \
        (adapSize.sizeForSorting()[1] < 1):
         tmpDict = {}
         tmpDict['oid'] = u"c%sstart_snmp_if_scanner" % objId
         tmpDict['title'] = _(u"start snmp interface scanner")
         tmpDict['href'] = u"%s/@@start_snmp_if_scanner.html" % \
                zapi.absoluteURL(self.context, self.request)
         tmpDict['tooltip'] = _(u"starts the interface scanner with snmp scan (as user:%s)"\
                                % self.request.principal.title)
         retList.append(tmpDict)
     return retList
Example #8
0
 def getStateDict(self):
     """get the object state in form of a dict
     """
     overviewNum = 0  # 0: ok, 1: warn, 2: error
     warnList = []
     errorList = []
     retDict = {}
     adapSize = ISized(self.context)
     # adapSize.sizeForSorting() returns ('item', n)
     if adapSize.sizeForSorting()[1] < 1:
         if overviewNum < 1:
             overviewNum = 1
         mesg = _(u'Warning: ')
         mesg += _(u"'no hosts in net'")
         warnList.append(mesg)
     retDict['overview'] = ('ok', 'warn', 'error')[overviewNum]
     retDict['warnings'] = warnList
     retDict['errors'] = errorList
     if overviewNum == 0:
         return None
     return retDict