本文整理汇总了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)
示例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)
示例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')
示例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)
示例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
示例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
示例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)