Exemplo n.º 1
0
def run():
    request = get_system_request()
    if request.user is None:
        # in test, db connection closed
        return

    catalog = find_catalog('dace')
    global last_transaction
    cache_key = _get_cache_key()
    last_transaction = last_transaction_by_machine.setdefault(cache_key, '')
    last_tid = catalog._p_jar.db().lastTransaction()
    if last_transaction != last_tid:
        last_transaction_by_machine[cache_key] = last_tid
        transaction.begin()
        try:
            system_actions = [
                a for a in getAllSystemActions()
                if getattr(a, 'process', None) or a.isstart
            ]
            log.info("new zodb transactions, actions to check: %s",
                     len(system_actions))
            for action in system_actions:
                _call_action(action)

        except Exception as e:
            log.exception(e)

        log.info("actions to check: done")

    run_crawler()
Exemplo n.º 2
0
def run():
    request = get_system_request()
    if request.user is None:
        # in test, db connection closed
        return

    catalog = find_catalog('dace')
    global last_transaction
    cache_key = _get_cache_key()
    last_transaction = last_transaction_by_machine.setdefault(cache_key, '')
    last_tid = catalog._p_jar.db().lastTransaction()
    if last_transaction != last_tid:
        last_transaction_by_machine[cache_key] = last_tid
        transaction.begin()
        try:
            system_actions = [a for a in getAllSystemActions()
                              if getattr(a, 'process', None) or
                              a.isstart]
            log.info("new zodb transactions, actions to check: %s",
                     len(system_actions))
            for action in system_actions:
                _call_action(action)

        except Exception as e:
            log.exception(e)

        log.info("actions to check: done")

    run_crawler()
Exemplo n.º 3
0
    def finish_behavior(self, work_item):
        super(EndEvent, self).finish_behavior(work_item)
        if isinstance(self.eventKind, TerminateEvent):
            return
        # Remove all workitems from process
        for node in self.process.nodes:
            try:
                node.stop()
                node.setproperty('workitems', [])
            except:
                pass

        self.process._finished = True
        registry = get_current_registry()
        registry.notify(ProcessFinished(self))
        current_process = self.process
        if current_process.definition.isSubProcess:
            try:
                request = get_system_request()
                root_process = current_process.attachedTo.process
                current_process.attachedTo.finish_execution(None, request)
                root_process.execution_context.remove_sub_execution_context(
                    current_process.execution_context)
                parent_node = current_process.attachedTo.node
                if current_process in parent_node.sub_processes:
                    parent_node.sub_processes.remove(current_process)
            except AttributeError as error:
                # the root process is a volatile subprocess (is removed)
                log.warning(error)

        if current_process.definition.isVolatile and \
           getattr(current_process, '__property__', None):
            getattr(current_process.__parent__.__class__,
                    current_process.__property__).remove(
                        current_process.__parent__, current_process)
Exemplo n.º 4
0
    def finish_behavior(self, work_item):
        super(EndEvent, self).finish_behavior(work_item)
        if isinstance(self.eventKind, TerminateEvent):
            return
        # Remove all workitems from process
        for node in self.process.nodes:
            try:
                node.stop()
                node.setproperty('workitems', [])
            except:
                pass

        self.process._finished = True
        registry = get_current_registry()
        registry.notify(ProcessFinished(self))
        current_process = self.process
        if current_process.definition.isSubProcess:
            try:
                request = get_system_request()
                root_process = current_process.attachedTo.process
                current_process.attachedTo.finish_execution(None, request)
                root_process.execution_context.remove_sub_execution_context(
                    current_process.execution_context)
                parent_node = current_process.attachedTo.node
                if current_process in parent_node.sub_processes:
                    parent_node.sub_processes.remove(current_process)
            except AttributeError as error:
                # the root process is a volatile subprocess (is removed)
                log.warning(error)

        if current_process.definition.isVolatile and \
           getattr(current_process, '__property__', None):
            getattr(current_process.__parent__.__class__,
                    current_process.__property__).remove(
                        current_process.__parent__, current_process)
Exemplo n.º 5
0
def _call_action(action):
    transaction.begin()
    try:
        context = action.get_potential_context()
        if context is None:
            return

        request = get_system_request()
        request.invalidate_cache = True
        action.execute(context, request, {})
        log.info("Execute action %s", action.title)
        transaction.commit()
    except Exception as e:
        transaction.abort()
        log.exception(e)
Exemplo n.º 6
0
def _call_action(action):
    transaction.begin()
    try:
        context = action.get_potential_context()
        if context is None:
            return

        request = get_system_request()
        request.invalidate_cache = True
        action.execute(context, request, {})
        log.info("Execute action %s", action.title)
        transaction.commit()
    except Exception as e:
        transaction.abort()
        log.exception(e)
Exemplo n.º 7
0
def _get_cache_key():
    request = get_system_request()
    return str(get_oid(request.user))
Exemplo n.º 8
0
def _get_cache_key():
    request = get_system_request()
    return str(get_oid(request.user))