当前位置: 首页>>代码示例>>Python>>正文


Python BibWorkflowObject.create_object方法代码示例

本文整理汇总了Python中invenio.modules.workflows.models.BibWorkflowObject.create_object方法的典型用法代码示例。如果您正苦于以下问题:Python BibWorkflowObject.create_object方法的具体用法?Python BibWorkflowObject.create_object怎么用?Python BibWorkflowObject.create_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在invenio.modules.workflows.models.BibWorkflowObject的用法示例。


在下文中一共展示了BibWorkflowObject.create_object方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_restart_failed_workflow

# 需要导入模块: from invenio.modules.workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import create_object [as 别名]
    def test_restart_failed_workflow(self):
        """Test restarting workflow for given workflow id."""
        from invenio.modules.workflows.models import (BibWorkflowObject,
                                                      ObjectVersion)
        from invenio.modules.workflows.engine import WorkflowStatus
        from invenio.modules.workflows.api import start, start_by_oids
        from invenio.modules.workflows.errors import WorkflowError

        initial_data = BibWorkflowObject.create_object()
        initial_data.set_data(1)
        initial_data.save()

        self.assertRaises(
            WorkflowError,
            start,
            workflow_name="test_workflow_error",
            data=[initial_data],
            module_name="unit_tests"
        )
        self.assertEqual(initial_data.version, ObjectVersion.ERROR)

        restarted_workflow = start_by_oids("test_workflow",
                                           oids=[initial_data.id],
                                           module_name="unit_tests")
        self.assertEqual(initial_data.version, ObjectVersion.WAITING)
        self.assertEqual(restarted_workflow.status, WorkflowStatus.HALTED)
开发者ID:kasioumis,项目名称:invenio,代码行数:28,代码来源:test_workflows.py

示例2: demoform

# 需要导入模块: from invenio.modules.workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import create_object [as 别名]
def demoform():
    """View for INSPIRE demo form."""
    # from inspire.modules.forms.utils import DataExporter

    form = DemoForm(data={"nickname": "John Doe"})
    ctx = {
        "action": url_for('.demoform'),
        "name": "inspireForm",
        "id": "inspireForm",
    }
    if form.validate_on_submit():
        # If it is needed to post process the form keys, for example to match
        # the names in the JSONAlchemy, one can use the DataExporter.
        # The keys will then be renamed using `export_key` parameter.
        # visitor = DataExporter()
        # visitor.visit(form)
        # visitor.data
        from invenio.modules.workflows.models import BibWorkflowObject
        from flask.ext.login import current_user
        myobj = BibWorkflowObject.create_object(id_user=current_user.get_id())
        myobj.set_data(form.data)
        # Start workflow. delayed=True will execute the workflow in the
        # background using, for example, Celery.
        myobj.start_workflow("demoworkflow", delayed=True)
        return render_template('forms/form_demo_success.html', form=form)
    return render_template('forms/form_demo.html', form=form, **ctx)
开发者ID:Lilykos,项目名称:inspire-next,代码行数:28,代码来源:views.py

示例3: submitnew

# 需要导入模块: from invenio.modules.workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import create_object [as 别名]
def submitnew():
    """Form action handler for INSPIRE author new form."""
    from inspire.modules.forms.utils import DataExporter
    from invenio.modules.workflows.models import BibWorkflowObject
    from flask.ext.login import current_user
    form = AuthorUpdateForm(formdata=request.form)
    visitor = DataExporter()
    visitor.visit(form)

    myobj = BibWorkflowObject.create_object(id_user=current_user.get_id())
    myobj.set_data(visitor.data)
    # Start workflow. delayed=True will execute the workflow in the
    # background using, for example, Celery.
    myobj.start_workflow("authornew", delayed=True)

    return render_template('authors/forms/new_success.html')
开发者ID:Lilykos,项目名称:inspire-next,代码行数:18,代码来源:views.py

示例4: run_harvest

# 需要导入模块: from invenio.modules.workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import create_object [as 别名]
def run_harvest(workflow, **kwargs):
    """Run given harvesting workflow in Celery."""
    from invenio.modules.workflows.models import BibWorkflowObject

    args = {
        "workflow": workflow
    }
    args.update(**kwargs)

    data = BibWorkflowObject.create_object()
    extra_data = data.get_extra_data()
    extra_data["args"] = args
    data.set_extra_data(extra_data)
    data.set_data({})
    data.save()
    data.start_workflow(workflow, delayed=True)
开发者ID:Lilykos,项目名称:inspire-next,代码行数:18,代码来源:__init__.py

示例5: __init__

# 需要导入模块: from invenio.modules.workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import create_object [as 别名]
    def __init__(self, workflow_object, type=None, user_id=None):
        self.workflow_object = workflow_object
        if not workflow_object:
            self.files = []
            self.drafts = {}
            self.type = self.get_type(type)
            self.title = ''
            self.sips = []

            self.workflow_object = BibWorkflowObject.create_object(
                id_user=user_id,
            )
            self.workflow_object.set_data({})
        else:
            self.__setstate__(workflow_object.get_data())
        self.engine = None
开发者ID:mhellmic,项目名称:b2share,代码行数:18,代码来源:models.py

示例6: __init__

# 需要导入模块: from invenio.modules.workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import create_object [as 别名]
    def __init__(self, workflow_object, type=None, user_id=None):
        """Init."""
        self.workflow_object = workflow_object
        if not workflow_object:
            self.files = []
            self.drafts = {}
            self.type = self.get_type(type)
            self.title = ''
            self.sips = []

            self.workflow_object = BibWorkflowObject.create_object(
                id_user=user_id,
            )
            # Ensure default data is set for all objects.
            self.update()
        else:
            self.__setstate__(workflow_object.get_data())
        self.engine = None
开发者ID:dset0x,项目名称:invenio,代码行数:20,代码来源:models.py

示例7: run_harvest

# 需要导入模块: from invenio.modules.workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import create_object [as 别名]
def run_harvest(workflow, **kwargs):
    """Run given harvesting workflow in Celery."""
    from invenio.base.globals import cfg
    from invenio.modules.workflows.models import BibWorkflowObject

    args = {
        "workflow": workflow
    }
    args.update(**kwargs)

    data = BibWorkflowObject.create_object()
    extra_data = data.get_extra_data()
    extra_data["args"] = args
    extra_data["config"] = cfg["HARVESTER_WORKFLOWS_CONFIG"].get(workflow, {})
    data.set_extra_data(extra_data)
    data.set_data({})
    data.save()
    data.start_workflow(workflow, delayed=True)
开发者ID:annetteholtkamp,项目名称:inspire-next,代码行数:20,代码来源:__init__.py


注:本文中的invenio.modules.workflows.models.BibWorkflowObject.create_object方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。