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


Python BibWorkflowObject.create_object方法代码示例

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


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

示例1: test_payload_file_creation

# 需要导入模块: from invenio_workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio_workflows.models.BibWorkflowObject import create_object [as 别名]
    def test_payload_file_creation(self):
        """Can add a file to a Payload."""
        from invenio_workflows.models import BibWorkflowObject
        from inspire.modules.workflows.models import Payload
        from inspire.utils.helpers import (
            get_file_by_name,
            add_file_by_name,
        )

        obj = BibWorkflowObject.create_object()
        obj.save()
        obj.data = obj.get_data()  # FIXME hack until workflow 2.0

        payload = Payload.create(workflow_object=obj, type="payload_fixture")
        payload.save()

        fd, filename = tempfile.mkstemp()
        os.close(fd)

        newpath = add_file_by_name(payload, filename)
        self.assertTrue(newpath)

        self.assertTrue(get_file_by_name(payload,
                                         os.path.basename(filename)))
        BibWorkflowObject.delete(obj)
开发者ID:Dziolas,项目名称:inspire-next,代码行数:27,代码来源:test_workflows.py

示例2: demoform

# 需要导入模块: from invenio_workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio_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_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:jalavik,项目名称:inspire-next,代码行数:28,代码来源:views.py

示例3: test_restart_failed_workflow

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

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

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

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

示例4: __init__

# 需要导入模块: from invenio_workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio_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:inspirehep,项目名称:invenio-deposit,代码行数:18,代码来源:models.py

示例5: run_harvest

# 需要导入模块: from invenio_workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio_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_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:jma,项目名称:inspire-next,代码行数:20,代码来源:__init__.py

示例6: submitupdate

# 需要导入模块: from invenio_workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio_workflows.models.BibWorkflowObject import create_object [as 别名]
def submitupdate():
    """Form action handler for INSPIRE author update form."""
    from inspirehep.modules.forms.utils import DataExporter
    from invenio_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("authorupdate", delayed=True)

    ctx = {
        "inspire_url": get_inspire_url(visitor.data)
    }

    return render_template('authors/forms/update_success.html', **ctx)
开发者ID:jochenklein,项目名称:inspire-next,代码行数:21,代码来源:views.py


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