Ejemplo n.º 1
0
 def __init__(self, **data):
     """
     constructor of Superclass
     """
     Persistent.__init__(self)
     ISuperclass['objectID'].readonly = False
     self.objectID = generateOid(self)
     self.ikName = self.objectID
     for (name, value) in data.items():
         if name in ISuperclass.names():
             setattr(self, name, value)
     ISuperclass['objectID'].readonly = True
     self.ikAuthor = u""
     self.dbgLevel = NOTSET
     self.history = RingBuffer(20)
     self.inpEQueue = Queue()
     self.outEQueue = Queue()
     self.outEReceiver = None
     self.workflows = {}
     self.wf_worklist = []
     interaction = queryInteraction()
     if interaction is not None:
         for participation in interaction.participations:
             #principalid = participation.principal.id
             principal_title = participation.principal.title
             self.ikAuthor += unicode(principal_title)
     self.myFactory = str(self.__class__).split("'")[1]
     self.ikRevision = __version__
Ejemplo n.º 2
0
 def makeAttributeTable(self):
     data = []
     fields = self.getReportFields()
     for f_name, f_obj in fields.items():
         f_val = getattr(self.context, f_name)
         namePara = self._convertNamePara(f_obj)
         if f_val is not None:
             if f_name in ['user', 'productionState']:
                 token = self._getVocabValue(f_obj.field.vocabularyName,
                                             f_val)
                 valPara = self._convertValPara(token)
                 data.append([namePara, valPara])                    
             elif type(f_val) is str or \
                type(f_val) is unicode:
                 valPara = self._convertValPara(f_val)
                 data.append([namePara, valPara])
             elif ISuperclass.providedBy(f_val):
                 valPara = self._convertValPara(f_val)
                 data.append([namePara, valPara])
             else:
                 if type(f_val) is list:
                     valParas = []
                     for i in f_val:
                         valParas.append(self._convertValPara(i))
                     if len(valParas) >= 1:
                         data.append([namePara, valParas])
                 else:
                     valPara = self._convertValPara(f_val)
                     data.append([namePara, valPara])
     return data
Ejemplo n.º 3
0
    def anchor(value, item, formatter):
        """ anchor method will return a html formated anchor"""
        if value is None:
            return u''
        if type(item) is dict:
            item = item['obj']
        if ISuperclass.providedBy(value):
            item = value
            value = item.ikName
        try:
            myAdapter = zapi.queryMultiAdapter((item, formatter.request),
                                               name=view)
            if myAdapter is not None and canAccess(myAdapter,'render'):
                url = absoluteURL(item, formatter.request) + '/' + view
                return u'<a href="%s">%s</a>' % (url, value)
            else:
#                view = "details.html"
                myAdapter = zapi.queryMultiAdapter((item, formatter.request),
                                                   name="details.html")
                if myAdapter is not None and canAccess(myAdapter,'render'):
                    url = absoluteURL(item, formatter.request) + '/' + "details.html"
                    return u'<a href="%s">%s</a>' % (url, value)
                else:
                    return u'%s' % (value)
        except Exception:
            return u'%s' % (value)
Ejemplo n.º 4
0
 def handleDelete(self, action):
     """delete was pressed"""
     if ISuperclass.providedBy(self.context):
         parent = self.getContent().__parent__
         del parent[self.context.objectID]
         self.deleted = True
         self.context = parent
         url = absoluteURL(parent, self.request)
         self.request.response.redirect(url)
Ejemplo n.º 5
0
 def traverse4Rpt(self, level, comments):
     """object pdf report
     
     level: indent-level (int 0..)
     comments: should there comments are in the output?
     """
     if ISuperclass.providedBy(self.context):
         self.traverse4RptPre(level, comments)
         self.traverse4RptBody(level, comments)
         self.traverse4RptPost(level, comments)
Ejemplo n.º 6
0
 def objs(self):
     """List of Content objects"""
     retList = []
     try:
         for obj in self.context.values():
             if ISuperclass.providedBy(obj):
                 retList.append(obj)
     except:
         pass
     return retList
Ejemplo n.º 7
0
def updateSuperclassDCTitle(ikObject, event):
    """
    Update an object's Dublin Core Title and back
    """
    for i in event.descriptions:
        if ISuperclass.isEqualOrExtendedBy(i.interface):
            dcore = IWriteZopeDublinCore(ikObject)
            dcore.title = ikObject.ikName
        if IZopeDublinCore.isEqualOrExtendedBy(i.interface):
            dcore = IZopeDublinCore(ikObject)
            ikObject.ikName = dcore.title
Ejemplo n.º 8
0
 def handleDelete(self, action):
     """delete was pressed"""
     if ISuperclass.providedBy(self.context):
         parent = self.context.__parent__
         del parent[self.context.objectID]
         self.deleted = True
         self.context = parent
         url = absoluteURL(parent, self.request)
         self.request.response.redirect(url)
         # workaround for gocept.objectquery
         import transaction
         transaction.savepoint()
Ejemplo n.º 9
0
 def handleDelete(self, action):
     """delete was pressed"""
     if ISuperclass.providedBy(self.context):
         parent = self.context.__parent__
         parentList = list(parent.items())
         oname = [oname for oname, oobj in parentList \
                  if oobj == self.context][0]
         del parent[oname]
         self.deleted = True
         self.context = parent
         url = absoluteURL(parent, self.request)
         self.request.response.redirect(url)
Ejemplo n.º 10
0
 def traverse4Rpt(self, level, comments):
     """object pdf report
     
     level: indent-level (int 0..)
     comments: should there comments are in the output?
     """
     if ISuperclass.providedBy(self.context):
         self.traverse4RptPre(level, comments)
         self.traverse4RptBody(level, comments)
         self.traverse4RptPost(level, comments)
         if self.document is not None and \
             self.document._reporter is not None:
             self.document._reporter.alreadyReported[self.context.objectID] = self
Ejemplo n.º 11
0
 def objs(self):
     """List of Content objects"""
     objWithPermisson = []
     #        allObj = getAllUtilitiesRegisteredFor(ISuperclass)
     #        allObj = getAllUtilitiesRegisteredFor(Interface, context=self.context)
     smFolder = self.context.getParent()
     allObj = smFolder.values()
     for obj in allObj:
         if ISuperclass.providedBy(obj):
             myAdapter = zapi.queryMultiAdapter((obj, self.request),
                                                name='details.html')
             if myAdapter is not None and canAccess(myAdapter, 'render'):
                 objWithPermisson.append(obj)
     return objWithPermisson
Ejemplo n.º 12
0
 def getSortKey(self, item, formatter):
     if ISuperclass.providedBy(self.getter(item, formatter)):
         key = self.getter(item, formatter).ikName
         if key is not None:
             key = key.lower()
         else:
             key = u'\xffff' * 80
         return key
     else:
         key = self.getter(item, formatter)
         if key is not None:
             key = key.lower()
         else:
             key = u'\xffff' * 80
         return key
Ejemplo n.º 13
0
 def handleDelete(self, action):
     """delete was pressed"""
     self.deleted = False
     objList = self.getContent().components
     nameList = [obj.ikName for obj in objList]
     if len(objList) > 0:
         self.deleted = False
         self.status = u"already used in: '%s'" % "' ,'".join(nameList)
     else:
         if ISuperclass.providedBy(self.context):
             parent = self.getContent().__parent__
             del parent[self.context.objectID]
             self.deleted = True
             self.context = parent
             url = absoluteURL(parent, self.request)
             self.request.response.redirect(url)
Ejemplo n.º 14
0
 def traverse4honeydGeneratorBody(self, cfgFile, level=0, comments=True):
     """graphviz configuration data of/in object
     """
     if comments:
         print >> cfgFile, "%s## Body (%s,%d) - SupernodeGenHoneyd" % \
               ("\t" * level, self.context.__name__, level)
     its = self.context.items()
     for (dummy_name, oobj) in its:
         if ISuperclass.providedBy(oobj):
             try:
                 adapterGenHoneyd = IIKGenHoneyd(oobj)
                 if adapterGenHoneyd:
                     adapterGenHoneyd.traverse4honeydGenerator(
                         cfgFile, level + 1, comments)
             except TypeError:
                 logger.error(u"Problem in adaption of honeyd config")
Ejemplo n.º 15
0
 def traverse4nagiosGeneratorBody(self, fileDict, level=0, comments=True):
     """graphviz configuration data of/in object
     """
     if comments:
         print >> fileDict['HostCfg'], \
               "%s## Body (%s,%d) - SupernodeGenNagios" % \
               ("\t" * level, self.context.ikName, level)
     its = self.context.items()
     for (dummy_name, oobj) in its:
         if ISuperclass.providedBy(oobj):
             try:
                 adapterGenNagios = IGenNagios(oobj)
                 if adapterGenNagios:
                     adapterGenNagios.traverse4nagiosGenerator(
                         fileDict, level + 1, comments)
             except TypeError:
                 logger.error(u"Problem in adaption of nagios config")
Ejemplo n.º 16
0
 def traverse4DotGenerator(self,
                           cfgFile,
                           level=0,
                           comments=True,
                           request=None,
                           alreadySeenList=None):
     """
     cfgFile: handle to open file
     level: indent-level
     """
     if ISuperclass.providedBy(self.context):
         self.traverse4DotGeneratorPre(cfgFile, level, comments, request,
                                       alreadySeenList)
         self.traverse4DotGeneratorBody(cfgFile, level, comments, request,
                                        alreadySeenList)
         self.traverse4DotGeneratorPost(cfgFile, level, comments, request,
                                        alreadySeenList)
Ejemplo n.º 17
0
 def traverse4nagiosGeneratorBody(self, level=0, comments=True):
     """graphviz configuration data of/in object
     """
     if comments:
         self.write("%s## Body (%s,%d) - SupernodeGenNagios" % \
                    ("\t" * level, self.context.ikName, level))
     its = self.context.items()
     for (dummy_name, oobj) in its:
         if ISuperclass.providedBy(oobj):
             try:
                 adapterGenNagios = IGenNagios(oobj)
                 if adapterGenNagios:
                     adapterGenNagios.parentAdapter = self
                     adapterGenNagios.traverse4nagiosGenerator(
                         level + 1, comments)
             except TypeError, errText:
                 logger.error(u"Problem in nagios adaption: '%s'" % \
                              errText)
Ejemplo n.º 18
0
 def handleDelete(self, action):
     """delete was pressed"""
     self.deleted = False
     if self.getContent().wasUsed:
         self.deleted = False
         self.status = u"already used"
     else:
         if ISuperclass.providedBy(self.context):
             sitem = getSiteManager(self)
             parent = self.getContent().__parent__
             sitem.unregisterUtility(component=self.getContent(),
                                     provided=IIdChooser,
                                     name=self.getContent().ikName)
             del parent[self.context.objectID]
             self.deleted = True
             self.context = parent
             url = absoluteURL(parent, self.request)
             self.request.response.redirect(url)
Ejemplo n.º 19
0
 def render(self):
     """Return the template with the option 'menus'"""
     objWithPermisson = []
     utilManager = getUtility(IUtilManager)
     smFolder = utilManager.getParent()
     allObj = smFolder.values()
     for obj in allObj:
         if ISuperclass.providedBy(obj):
             if canAccess(obj, 'ikName'):
                 myAdapter = zapi.queryMultiAdapter((obj, self.request),
                                                    name='details.html')
                 if myAdapter is not None and canAccess(
                         myAdapter, 'render'):
                     objWithPermisson.append(obj)
     if len(objWithPermisson) > 0:
         return self.template()
     else:
         return u''
Ejemplo n.º 20
0
 def _convertValPara(self, f_val):
     if ISuperclass.providedBy(f_val):
         rptAdapter = IRptPdf(f_val)
         rptAdapter.request = self.request
         rptAdapter.document = self.document
         iText = rptAdapter.getRefTitle()
     else:
         #            if isOidInCatalog(f_val):
         #                iText = translate(oid2dcTitle(f_val),
         #                                  domain='org.ict_ok',
         #                                  context=self.request)
         #            else:
         iText = translate(unicode(f_val),
                           domain='org.ict_ok',
                           context=self.request)
     rptPara = RptPara(iText,
                       style=self.document.styles['Normal'],
                       doc=self.document)
     return rptPara
Ejemplo n.º 21
0
def getEvaluationsTodo(context):
    """List of Content objects"""
    retSet = set([])
    my_catalog = zapi.getUtility(ICatalog)
    if hasattr(context, "requirements"):
        if context.requirements is not None:
            for requirement in context.requirements:
                if ISuperclass.providedBy(requirement):
                    res = my_catalog.searchResults(oid_index=requirement.objectID)
                else:
                    res = my_catalog.searchResults(oid_index=requirement)
                if len(res) > 0:
                    startReq = iter(res).next()
                    allObjReqs = getRequirementList(startReq)
                    allObjEvaluations = getEvaluationsDone(context)
                    alreadyCheckedReqs = [ev[0] for ev in allObjEvaluations.items()]
                    #retList.extend(set(allObjReqs).difference(alreadyCheckedReqs))
                    retSet = retSet.union(set(allObjReqs).difference(alreadyCheckedReqs))
    #        return retList
    return list(retSet)
Ejemplo n.º 22
0
    def exportXmlData(self):
        """get data file for all objects"""
        #dataStructure = {
        #'objects': ['a', 'b', 'c'],
        #'conns': [1, 2, 3],
        #}
        dataStructure = {
            'objects': [],
        }
        its = self.items()
        for (dummy_name, oobj) in its:
            if ISuperclass.providedBy(oobj):
                dataStructure['objects'].append(oobj.ikName)
#        sitemanger = zapi.getParent(self)
#        locSitemanager = zapi.getParent(sitemanger)
#        root_folder = zapi.getParent(locSitemanager)
#        for folder in root_folder.values():
#            for obj in folder.values():
#                obj.getAllExportData(dataStructure)
        python_pickle = pickle.dumps(dataStructure)
        return toxml(python_pickle)
Ejemplo n.º 23
0
 def generateAllPdf(self, absFilename, authorStr, versionStr):
     """
     will generate a complete pdf report
     """
     files2delete = []
     document = RptDocument(absFilename)
     document.setAuthorName(authorStr)
     document.setVersionStr(versionStr)
     its = self.items()
     for (dummy_name, oobj) in its:
         if ISuperclass.providedBy(oobj):
             try:
                 adapterRptPdf = IRptPdf(oobj)
                 if adapterRptPdf:
                     adapterRptPdf.document = document
                     adapterRptPdf.traverse4Rpt(1, False)
                     files2delete.extend(adapterRptPdf.files2delete)
                     del adapterRptPdf
             except TypeError, errText:
                 logger.error(u"Problem in adaption of pdf report: %s" %\
                              (errText))
Ejemplo n.º 24
0
 def traverse4RptBody(self, level, comments):
     """pdf report data of/in object
     
     level: indent-level (int 0..)
     comments: should there comments are in the output?
     """
     if comments:
         self.writeComment(u"%s## Body (%s,%d) - Product" % \
                           ("\t" * level, self.context.ikName, level))
     its = self.context.subProducts
     for oobj in its:
         if ISuperclass.providedBy(oobj):
             try:
                 adapterRptPdf = IRptPdf(oobj)
                 if adapterRptPdf:
                     adapterRptPdf.document = self.document
                     adapterRptPdf.traverse4Rpt(level + 1, comments)
                     self.files2delete.extend(adapterRptPdf.files2delete)
                     del adapterRptPdf
             except TypeError, errText:
                 logger.error(u"Problem in adaption: %s (%s)" %\
                              (errText, oobj.ikName))
Ejemplo n.º 25
0
 def traverse4RptBody(self, level, comments):
     """xml report data of/in object
     
     level: indent-level (int 0..)
     comments: should there comments are in the output?
     """
     if comments:
         self.writeComment(u"%s## Body (%s,%d) - SupernodeRptXMLBody" % \
                           ("\t" * level, self.context.ikName, level))
     its = self.context.items()
     for (dummy_name, oobj) in its:
         if ISuperclass.providedBy(oobj):
             try:
                 adapterRptXML = IRptXML(oobj)
                 if adapterRptXML:
                     adapterRptXML.document = self.document
                     adapterRptXML.traverse4Rpt(level + 1, comments)
                     #self.files2delete.extend(adapterRptPdf.files2delete)
                     del adapterRptXML
             except TypeError, errText:
                 logger.error(u"Problem in adaption: %s (%s)" %\
                              (errText, oobj.ikName))
Ejemplo n.º 26
0
 def objs(self):
     """List of Content objects"""
     return [obj
             for obj in self.context.values()
             if ISuperclass.providedBy(obj)]
Ejemplo n.º 27
0
 def update(self):
     """update all widgets"""
     if ISuperclass.providedBy(self.context):
         self.label = self.context.ikName
     form.Form.update(self)
Ejemplo n.º 28
0
 def appendReqXmlData(self, objects, rootElement):
     for (dummy_name, oobj) in objects:
         if ISuperclass.providedBy(oobj):
             rootElement.append(oobj.asETree())
Ejemplo n.º 29
0
def allNotifySubscriber(event):
    if not ISuperclass.providedBy(event.object):
        return
    notifierUtil = queryUtility(INotifierUtil)
    notifierUtil.sendNotify(event, event.object)
Ejemplo n.º 30
0
    def traverse4DotGeneratorBody(self, \
                                  cfgFile, \
                                  level=0, \
                                  comments=True,
                                  signalsOutput=False,
                                  recursive=True):
        """Pre-Text in graphviz dot-file"""
        if comments:
            print >> cfgFile, "%s// Body (%s,%d) - SupernodeGenGraphvizDot" \
                  % ("\t" * level, self.context.__name__, level)

        print >> cfgFile, '%s"%s" [' % ("\t" * level, self.context.objectID)
        print >> cfgFile, '%sshape="plaintext",' % ("\t" * (level + 1))
        print >> cfgFile, '%sstyle="filled,setlinewidth(0)",' \
              % ("\t" * (level + 1))
        print >> cfgFile, '%sfillcolor = chartreuse2,' % ("\t" * (level + 1))
        print >> cfgFile, '%smargin = 0,' % ("\t" * (level + 1))
        print >> cfgFile, '%shref = "%s/@@details.html",' \
              % ("\t" * (level + 1), zapi.getPath(self.context))

        #print >> cfgFile, '%slabel = <<TABLE BORDER = "0" CELLBORDER = "0" ' \
        #'CELLPADDING = "0" CELLSPACING = "0"><TR><TD>' \
        #'<IMG SRC = "/home/markus/Projekte/IKOMtrol-hp/apple-red.png"/>' \
        #'</TD></TR><TR><TD><FONT FACE = "Arial" POINT-SIZE = "10">%s' \
        #'</FONT></TD></TR></TABLE>>' \
        #% ("\t" * (level + 1), self.context.ikName)

        print >> cfgFile, '%slabel = <' % ("\t" * (level + 1))
        print >> cfgFile, '%s<TABLE BORDER="0" CELLBORDER="1" CELLPADDING = "2" CELLSPACING = "0">' % (
            "\t" * (level + 1))
        print >> cfgFile, '%s<TR><TD WIDTH="120px">%s</TD></TR>' % (
            "\t" * (level + 1), self.context.ikName)
        if signalsOutput:
            allInpNamesDict = self.context.getAllInpEventNames()
            for inpName in allInpNamesDict.keys():
                print >> cfgFile, '%s<TR><TD ALIGN="LEFT" PORT="%s" '\
                      'BGCOLOR="yellow">%s</TD></TR>' % \
                      ("\t" * (level + 1), inpName, inpName)
            allOutNamesDict = self.context.getAllOutEventNames()
            for outName in allOutNamesDict.keys():
                print >> cfgFile, '%s<TR><TD ALIGN="RIGHT" PORT="%s" '\
                      'BGCOLOR="orange">%s</TD></TR>' % \
                      ("\t" * (level + 1), outName, outName)
        #print >> cfgFile, '%s<TR><TD ALIGN="LEFT" PORT="sig_inp1" BGCOLOR="yellow">sig_inp1</TD></TR>' % ("\t" * (level + 1))
        #print >> cfgFile, '%s<TR><TD ALIGN="LEFT" PORT="sig_inp2" BGCOLOR="yellow">sig_inp2</TD></TR>' % ("\t" * (level + 1))
        #print >> cfgFile, '%s<TR><TD ALIGN="RIGHT" PORT="sig_out1" BGCOLOR="orange">sig_out1</TD></TR>' % ("\t" * (level + 1))
        print >> cfgFile, '%s</TABLE>>' % ("\t" * (level + 1))
        print >> cfgFile, '%s]; // %s' % ("\t" * level, self.context.__name__)
        if recursive:
            its = self.context.items()
        else:
            its = []
        for (dummy_name, oobj) in its:
            if ISuperclass.providedBy(oobj):
                try:
                    adapterGenGraphvizDot = IGenGraphvizDot(oobj)
                    if adapterGenGraphvizDot:
                        adapterGenGraphvizDot.setParent(self.context)
                        adapterGenGraphvizDot.traverse4DotGenerator(\
                            cfgFile, level + 1, comments, signalsOutput)
                except TypeError, err:
                    logging.error("Error in AdmUtilGraphviz::getRootDot()"\
                                  % err)