Ejemplo n.º 1
0
 def __init__(self, session, config, parent):
     SimpleWorkflow.__init__(self, session, config, parent)
     anlr = self.get_setting(session, 'analyzer')
     if anlr[-8:] == 'Analyzer' and hasattr(lucene, anlr):
         anlzClass = getattr(lucene, anlr)
         self.analyzer = anlzClass()
     else:
         raise ConfigFileException("Unknown Lucene Analyzer")
     pass
Ejemplo n.º 2
0
 def __init__(self, session, config, parent):
     SimpleWorkflow.__init__(self, session, config, parent)
     anlr = self.get_setting(session, 'analyzer')
     if anlr[-8:] == 'Analyzer' and hasattr(lucene, anlr):            
         anlzClass = getattr(lucene, anlr)
         self.analyzer = anlzClass()
     else:
         raise ConfigFileException("Unknown Lucene Analyzer")
     pass
    def handle_workflowRequest(self, config, req):
        postdata = FieldStorage(req)

        xmlstr = postdata.get('requestxml', None)

        if not (xmlstr):
            # throw some sensible error
            time.sleep(1)
            req.write('ERROR : No request XML submitted\n')
            return
#        else:
#            self.log.write(xmlstr)

        doc = document.StringDocument(xmlstr)
        rec = mdp.process_document(session, doc)

        self.log.write('rec.get_xml():\n%s\n' % rec.get_xml(session))

        dom = rec.get_dom(session)
        #now do some clever dynamic object stuff
        wfNode = dom.childNodes[0]
        wfNode = dom.getElementsByTagName('workflow')[0]
        wfConf = self._generateWorkflowConfigNode(wfNode)
        wfobj = SimpleWorkflow(session, wfConf, serv)
        inputs = dom.getElementsByTagName('inputs')[0]

        time.sleep(1)
        if not (wfobj):
            req.write('ERROR : Junk XML - must contain workflow element\n')
            return
        elif not (inputs):
            req.write('ERROR : Junk XML - must contain inputs element\n')
            return

        iCount = 1
        wfmsgs = []
        self.log.write('inputs:%s\n' % inputs.toxml())
        for input in inputs.childNodes:
            self.log.write('input:%s\n' % input.toxml())
            if (input.nodeType == elementType):
                objectType = input.getAttribute('type')
            else:
                continue

            if objectType == 'document.StringDocument':
                try:
                    f = postdata.get('file', None)
                    data = f.value
                except:
                    data = None
            else:
                data = input.firstChild.toxml()

            if not data:
                req.write('ERROR : No input data provided\n')
                return

            time.sleep(5)
            #req.write('PROGRESS : %s\n' % (objectType))
            modName = objectType[:objectType.rfind('.')]
            clName = objectType[objectType.rfind('.') + 1:]
            mod = dynamic.globalImport(modName, [])
            cl = getattr(mod, clName)
            inobj = cl(data)
            try:
                msg = wfobj.process(session, inobj)
            except ObjectAlreadyExistsException, e:
                time.sleep(1)
                req.write(
                    'ERROR : One or more records in input %d already exist in the database : %s\n'
                    % (iCount, e))
                continue
            except Exception, e:
                time.sleep(1)
                msg = e
                req.write(
                    'ERROR : Something went wrong while processing input %d : %s\n'
                    % (iCount, e))
                continue
Ejemplo n.º 4
0
 def __init__(self, session, config, parent):
     SimpleWorkflow.__init__(self, session, config, parent)
     raise MissingDependencyException(self.objectType, "lucene")
Ejemplo n.º 5
0
    def handle_workflowRequest(self, config, req):
        postdata = FieldStorage(req)
            
        xmlstr = postdata.get('requestxml', None)
        
        if not (xmlstr):
            # throw some sensible error
            time.sleep(1)
            req.write('ERROR : No request XML submitted\n')
            return
#        else:
#            self.log.write(xmlstr)
            
        doc = document.StringDocument(xmlstr)
        rec = mdp.process_document(session, doc)
        
        self.log.write('rec.get_xml():\n%s\n' % rec.get_xml(session))
        
        dom = rec.get_dom(session)
        #now do some clever dynamic object stuff
        wfNode = dom.childNodes[0]
        wfNode = dom.getElementsByTagName('workflow')[0]
        wfConf = self._generateWorkflowConfigNode(wfNode)
        wfobj = SimpleWorkflow(session, wfConf, serv)
        inputs = dom.getElementsByTagName('inputs')[0]
                        
        time.sleep(1);                      
        if not (wfobj): req.write('ERROR : Junk XML - must contain workflow element\n'); return
        elif not (inputs): req.write('ERROR : Junk XML - must contain inputs element\n'); return
        
        iCount = 1
        wfmsgs = []
        self.log.write('inputs:%s\n' % inputs.toxml())
        for input in inputs.childNodes:
            self.log.write('input:%s\n' % input.toxml())
            if (input.nodeType == elementType):
                objectType = input.getAttribute('type')
            else:
                continue
            
            if objectType == 'document.StringDocument':
                try: 
                    f = postdata.get('file', None)
                    data = f.value
                except: 
                    data = None
            else: 
                data = input.firstChild.toxml()
                
            if not data: req.write('ERROR : No input data provided\n'); return
                
            time.sleep(5);
            #req.write('PROGRESS : %s\n' % (objectType))
            modName = objectType[:objectType.rfind('.')]
            clName = objectType[objectType.rfind('.')+1:]
            mod = dynamic.globalImport(modName, [])
            cl = getattr(mod, clName)
            inobj = cl(data)
            try:
                msg = wfobj.process(session, inobj)
            except ObjectAlreadyExistsException, e:
                time.sleep(1);
                req.write('ERROR : One or more records in input %d already exist in the database : %s\n' % (iCount, e))
                continue
            except Exception, e:
                time.sleep(1);
                msg = e
                req.write('ERROR : Something went wrong while processing input %d : %s\n' % (iCount, e))
                continue
Ejemplo n.º 6
0
 def __init__(self, session, config, parent):
     SimpleWorkflow.__init__(self, session, config, parent)
     raise MissingDependencyException(self.objectType, "lucene")