Exemple #1
0
 def templatesOutThere(self):
     templatesOutThere = False
     for object in objectsWithInterface(self.attrInterface):
         if object.isTemplate:
             templatesOutThere = True
             break
     return templatesOutThere
Exemple #2
0
 def __init__(self, context, request, view, manager):
     GlobalMenuSubItem.__init__(self, context, request, view, manager)
     try:
         self.firstFolder = list(objectsWithInterface(
             self.folderInterface))[0]
     except IndexError:
         self.firstFolder = None
Exemple #3
0
 def match_requirements(self):
     """ match all Components with Categories on all Requirements with
     same Categories
     """
     objList = objectsWithInterface(IComponent)
     reqList = objectsWithInterface(IRequirement)
     for obj in objList:
         if len(obj.categories) > 0:
             for req in reqList:
                 if req.validAsFirst and len(req.categories) > 0:
                     obj_cat_set = set(obj.categories)
                     req_cat_set = set(req.categories)
                     if not obj_cat_set.isdisjoint(req_cat_set):
                         if not req in obj.requirements:
                             obj.requirements.append(req)
                             obj._p_changed = 1
Exemple #4
0
 def getFirstContainer(self):
     """
     """
     if self.containerIface is not None:
         return objectsWithInterface(self.containerIface).pop(0)
     else:
         return None
Exemple #5
0
def AllUnusedOrSelfComponents(dummy_context, interface, obj_attr_name,
                              *additionalAttrNames):
    """In which production state a host may be
    """
    terms = []
    for object in objectsWithInterface(interface):
        obj_attr = getattr(object, obj_attr_name, None)
        if obj_attr is None or \
            len(obj_attr) == 0:
            myString = object.ikName
            for additionalAttrName in additionalAttrNames:
                additionalAttribute = getattr(object, additionalAttrName, None)
                if additionalAttribute is not None:
                    if hasattr(additionalAttribute, 'ikName'):
                        if len(additionalAttribute.ikName) > 70:
                            dotted = u'...)'
                        else:
                            dotted = u')'
                        myString = myString + u" (%s" % \
                            additionalAttribute.ikName[:70] + dotted
                    else:
                        if len(additionalAttribute) > 70:
                            dotted = u'...)'
                        else:
                            dotted = u')'
                        myString = myString + u" (%s" % \
                            additionalAttribute[:70] + dotted
            terms.append(\
                SimpleTerm(object,
                           token=getattr(object, 'objectID', object.objectID),
                           title=myString))
        else:
            if obj_attr == dummy_context or \
                dummy_context in obj_attr:
                myString = u"%s" % (object.ikName)
                for additionalAttrName in additionalAttrNames:
                    additionalAttribute = getattr(object, additionalAttrName,
                                                  None)
                    if additionalAttribute is not None:
                        if hasattr(additionalAttribute, 'ikName'):
                            if len(additionalAttribute.ikName) > 70:
                                dotted = u'...)'
                            else:
                                dotted = u')'
                            myString = myString + u" (%s" % \
                                additionalAttribute.ikName[:70] + dotted
                        else:
                            if len(additionalAttribute) > 70:
                                dotted = u'...)'
                            else:
                                dotted = u')'
                            myString = myString + u" (%s" % \
                                additionalAttribute[:70] + dotted
                terms.append(\
                    SimpleTerm(object,
                               token=getattr(object, 'objectID', object.objectID),
                               title=myString))
    terms.sort(lambda l, r: cmp(l.title.lower(), r.title.lower()))
    return SimpleVocabulary(terms)
Exemple #6
0
 def isEmpty(self):
     """
     Table is empty
     """
     if hasattr(self, "objListInterface"):
         return len(objectsWithInterface(self.objListInterface)) < 1
     else:
         return len(self.context) < 1
Exemple #7
0
 def allReqsList(self):
     """List of Content objects"""
     retList = []
     objList = objectsWithInterface(IComponent)
     for obj in objList:
         evaluations = getEvaluationsTodo(obj)
         for ev in evaluations:
             retList.append({"req": ev, "obj": obj})
     return retList
Exemple #8
0
 def objs(self):
     """List of Content objects"""
     retList = []
     for object in objectsWithInterface(IComponent):
         tmp_health = object.get_health()
         if tmp_health is not None and \
            tmp_health < 0.9:
             retList.append(object)
     return retList
Exemple #9
0
def AllMobilePhones(dummy_context):
    """Which MobilePhone exists
    """
    terms = []
    for object in objectsWithInterface(IMobilePhone):
        myString = u"%s" % (object.getDcTitle())
        terms.append(SimpleTerm(object,
                                token=getattr(object, 'objectID'),
                                title=myString))
    return SimpleVocabulary(terms)
Exemple #10
0
def AllLocationsVocab(dummy_context):
    """Which locations are there
    """
    terms = []
    for object in objectsWithInterface(ILocation):
        terms.append(\
            SimpleTerm(object.objectID,
                       str(object.objectID),
                       object.getDcTitle()))
    return SimpleVocabulary(terms)
Exemple #11
0
def AllLocations(dummy_context):
    """In which production state a host may be
    """
    terms = []
    for object in objectsWithInterface(ILocation):
        myString = u"%s" % (object.getDcTitle())
        terms.append(\
            SimpleTerm(object,
                       token=getattr(object, 'objectID'),
                       title=myString))
    return SimpleVocabulary(terms)
Exemple #12
0
 def objs(self):
     """List of Content objects"""
     compactView = False
     userManagement = queryUtility(IAdmUtilUserManagement)
     if userManagement is not None and\
         userManagement.compactView is True:
         compactView = True
     if hasattr(self, "objListInterface"):
         if compactView:
             return [
                 obj for obj in objectsWithInterface(self.objListInterface)
                 if len(obj) > 0
             ]
         else:
             return objectsWithInterface(self.objListInterface)
     else:
         #return [obj for obj in self.context.values()]
         if compactView:
             return [obj for obj in self.context.values() if len(obj) > 0]
         else:
             return self.context.values()
Exemple #13
0
def AllLocationTemplates(dummy_context):
    """Which MobilePhone templates exists
    """
    terms = []
    for object in objectsWithInterface(ILocation):
        if object.isTemplate:
            myString = u"%s [T]" % (object.getDcTitle())
            terms.append(
                SimpleTerm(object,
                           token=getattr(object, 'objectID'),
                           title=myString))
    return SimpleVocabulary(terms)
Exemple #14
0
def AllSnmpValueTemplates(dummy_context):
    """Which SnmpValue templates exists
    """
    terms = []
    for object in objectsWithInterface(ISnmpValue):
        if object.isTemplate:
            myString = u"%s [T]" % (object.getDcTitle())
            terms.append(
                SimpleTerm(object,
                           token=getattr(object, 'objectID', object.objectID),
                           title=myString))
    return SimpleVocabulary(terms)
Exemple #15
0
def AllComponentTemplates(dummy_context, interface):
    """Which MobilePhone templates exists
    """
    #    print "AllComponentTemplates() ->", interface
    terms = []
    for object in objectsWithInterface(interface):
        if object.isTemplate:
            myString = u"%s [T]" % (object.getDcTitle())
            terms.append(
                SimpleTerm(object,
                           token=getattr(object, 'objectID', object.objectID),
                           title=myString))
    terms.sort(lambda l, r: cmp(l.title.lower(), r.title.lower()))
    return SimpleVocabulary(terms)
Exemple #16
0
 def createAndAdd(self, data):
     obj = self.create(data)
     notify(ObjectCreatedEvent(obj))
     self.add(obj)
     oneParent = None
     for object in objectsWithInterface(IInterfaceFolder):
         oneParent = object
         break
     if oneParent is not None and obj.ifCount != None:
         for i in range(1, obj.ifCount + 1):
             dataVect = {}
             dataVect['ikName'] = u'%s-%02d' % (obj.ikName, i)
             dataVect['device'] = obj
             newObj = Interface(**dataVect)
             newObj.__post_init__()
             IBrwsOverview(newObj).setTitle(dataVect['ikName'])
             oneParent[newObj.objectID] = newObj
             if hasattr(newObj, "store_refs"):
                 newObj.store_refs(**dataVect)
             notify(ObjectCreatedEvent(newObj))
     return obj
Exemple #17
0
def AllComponents(dummy_context,
                  interface=IComponent,
                  includeSelf=True,
                  *additionalAttrNames):
    """In which production state a host may be
    """
    terms = []
    for object in objectsWithInterface(interface):
        myString = u"%s" % (object.ikName)
        for additionalAttrName in additionalAttrNames:
            if additionalAttrName.count('.') == 1:
                (additionalAttrName1,additionalAttrName2) = \
                    additionalAttrName.split('.')
                myString += stringFromAttribute(object, additionalAttrName1)
                try:
                    attribute1 = getattr(object, additionalAttrName1, None)
                    if attribute1 is not None:
                        myString += stringFromAttribute(
                            attribute1, additionalAttrName2)
                except Exception:
                    pass
            elif additionalAttrName.count('.') == 0:
                myString += stringFromAttribute(object, additionalAttrName)
        if object == dummy_context:
            if includeSelf:
                terms.append(\
                    SimpleTerm(object,
                               token=getattr(object, 'objectID', object.objectID),
                               title=myString))
        else:
            terms.append(\
                SimpleTerm(object,
                           token=getattr(object, 'objectID', object.objectID),
                           title=myString))
    terms.sort(lambda l, r: cmp(l.title.lower(), r.title.lower()))
    return SimpleVocabulary(terms)
Exemple #18
0
def getAllServices():
    """ get a list of all services
    """
    return objectsWithInterface(IService)
Exemple #19
0
 def delete_requirements(self):
     """ delete all Categories from Components
     """
     objList = objectsWithInterface(IComponent)
     for obj in objList:
         obj.requirements = []
Exemple #20
0
def getFirstLevelObjectList(foldername):
    i_list = [object for object in objectsWithInterface(IProduct) \
              if object.mainProduct is None]
    i_list.sort(cmp=lambda x, y: x.ikName < y.ikName)
    return (foldername, i_list)
Exemple #21
0
def getAllHosts():
    """ get a list of all Hosts
    """
    return objectsWithInterface(IHost)