本文整理汇总了Python中opengever.task.task.ITask.names方法的典型用法代码示例。如果您正苦于以下问题:Python ITask.names方法的具体用法?Python ITask.names怎么用?Python ITask.names使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengever.task.task.ITask
的用法示例。
在下文中一共展示了ITask.names方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assign_forwarding_to_dossier
# 需要导入模块: from opengever.task.task import ITask [as 别名]
# 或者: from opengever.task.task.ITask import names [as 别名]
def assign_forwarding_to_dossier(
context, forwarding_oguid, dossier, response_text):
forwarding = Task.query.by_oguid(forwarding_oguid)
forwarding_obj = context.unrestrictedTraverse(
forwarding.physical_path.encode('utf-8'))
# we need all task field values from the forwarding
fielddata = {}
for fieldname in ITask.names():
value = ITask.get(fieldname).get(forwarding_obj)
fielddata[fieldname] = value
# Reset issuer to the current inbox
fielddata['issuer'] = get_current_org_unit().inbox().id()
# Predefine the task_type to avoid tasks with an invalid task_type
fielddata['task_type'] = FORWARDING_SUCCESSOR_TYPE
# lets create a new task - the successor task
task = createContentInContainer(
dossier, 'opengever.task.task', **fielddata)
successor_tc_task = ISuccessorTaskController(task)
# Add issuer and responsible to the watchers of the newly created task
center = notification_center()
center.add_task_responsible(task, task.responsible)
center.add_task_issuer(task, task.issuer)
# copy documents and map the intids
intids_mapping = _copy_documents_from_forwarding(forwarding_obj, task)
# copy the responses
response_transporter = IResponseTransporter(task)
response_transporter.get_responses(
get_current_admin_unit().id(),
'/'.join(forwarding_obj.getPhysicalPath()),
intids_mapping=intids_mapping)
# close and store the forwarding in yearfolder
change_task_workflow_state(
forwarding_obj,
'forwarding-transition-assign-to-dossier',
text=response_text,
successor_oguid=successor_tc_task.get_oguid())
IYearfolderStorer(forwarding_obj).store_in_yearfolder()
# successor
successor_tc_task.set_predecessor(forwarding_oguid)
return task
示例2: assign_forwarding_to_dossier
# 需要导入模块: from opengever.task.task import ITask [as 别名]
# 或者: from opengever.task.task.ITask import names [as 别名]
def assign_forwarding_to_dossier(
context, forwarding_oguid, dossier, response_text):
forwarding = getUtility(ITaskQuery).get_task_by_oguid(forwarding_oguid)
forwarding_obj = context.unrestrictedTraverse(
forwarding.physical_path.encode('utf-8'))
# we need all task field values from the forwarding
fielddata = {}
for fieldname in ITask.names():
value = ITask.get(fieldname).get(forwarding_obj)
fielddata[fieldname] = value
# lets create a new task - the successor task
task = createContentInContainer(
dossier, 'opengever.task.task', **fielddata)
successor_tc_task = ISuccessorTaskController(task)
# copy documents and map the intids
intids_mapping = _copy_documents_from_forwarding(forwarding_obj, task)
# copy the responses
response_transporter = IResponseTransporter(task)
response_transporter.get_responses(
get_client_id(),
'/'.join(forwarding_obj.getPhysicalPath()),
intids_mapping=intids_mapping)
# close and store the forwarding in yearfolder
change_task_workflow_state(
forwarding_obj,
'forwarding-transition-assign-to-dossier',
text=response_text,
successor_oguid=successor_tc_task.get_oguid())
inbox = aq_parent(aq_inner(forwarding_obj))
yearfolder = _get_yearfolder(inbox)
clipboard = inbox.manage_cutObjects((forwarding_obj.getId(),))
yearfolder.manage_pasteObjects(clipboard)
# successor
successor_tc_task.set_predecessor(forwarding_oguid)
return task
示例3: accept_forwarding_with_successor
# 需要导入模块: from opengever.task.task import ITask [as 别名]
# 或者: from opengever.task.task.ITask import names [as 别名]
def accept_forwarding_with_successor(
context, predecessor_oguid, response_text, dossier=None):
# the predessecor (the forwarding on the remote client)
predecessor = getUtility(ITaskQuery).get_task_by_oguid(predecessor_oguid)
# get the inbox
cat = getToolByName(context, 'portal_catalog')
inboxes = cat(portal_type="opengever.inbox.inbox")
if len(inboxes) == 0:
raise Unauthorized()
else:
inbox = inboxes[0].getObject()
# transport the remote forwarding to the inbox or actual yearfolder
transporter = getUtility(ITransporter)
if dossier:
yearfolder = _get_yearfolder(inbox, )
successor_forwarding = transporter.transport_from(
yearfolder, predecessor.client_id, predecessor.physical_path)
else:
successor_forwarding = transporter.transport_from(
inbox, predecessor.client_id, predecessor.physical_path)
# Replace the issuer with the current inbox
successor_forwarding.issuer = u'inbox:%s' % get_client_id()
# Set the "X-CREATING-SUCCESSOR" flag for preventing the event handler
# from creating additional responses per added document.
successor_forwarding.REQUEST.set('X-CREATING-SUCCESSOR', True)
successor_tc = ISuccessorTaskController(successor_forwarding)
# copy documents and map the intids
doc_transporter = getUtility(ITaskDocumentsTransporter)
with CustomInitialVersionMessage(
_(u'version_message_accept_forwarding',
default=u'Document copied from forwarding (forwarding accepted)'),
context.REQUEST):
intids_mapping = doc_transporter.copy_documents_from_remote_task(
predecessor, successor_forwarding)
# copy the responses
response_transporter = IResponseTransporter(successor_forwarding)
response_transporter.get_responses(predecessor.client_id,
predecessor.physical_path,
intids_mapping=intids_mapping)
# if a dossier is given means that a successor task must
# be created in a new or a existing dossier
if dossier:
# we need all task field values from the forwarding
fielddata = {}
for fieldname in ITask.names():
value = ITask.get(fieldname).get(successor_forwarding)
fielddata[fieldname] = value
# lets create a new task - the successor task
task = createContentInContainer(
dossier, 'opengever.task.task', **fielddata)
# copy documents and map the intids
intids_mapping = _copy_documents_from_forwarding(
successor_forwarding, task)
# copy the responses
response_transporter = IResponseTransporter(task)
response_transporter.get_responses(
get_client_id(),
'/'.join(successor_forwarding.getPhysicalPath()),
intids_mapping=intids_mapping)
# successor
successor_tc_task = ISuccessorTaskController(task)
transaction.savepoint()
# Close the predessecor forwarding
response_text = response_text or ''
request_data = {'response_text': response_text.encode('utf-8'),
'successor_oguid': successor_tc.get_oguid(),
'transition': 'forwarding-transition-accept'}
response = remote_request(predecessor.client_id,
'@@store_forwarding_in_yearfolder',
path=predecessor.physical_path,
data=request_data)
if response.read().strip() != 'OK':
raise Exception('Adding the response and changing the '
'workflow state on the predecessor forwarding '
'failed.')
if dossier:
# when a successor task exists, we close also the successor forwarding
change_task_workflow_state(
successor_forwarding,
'forwarding-transition-accept',
#.........这里部分代码省略.........
示例4: accept_forwarding_with_successor
# 需要导入模块: from opengever.task.task import ITask [as 别名]
# 或者: from opengever.task.task.ITask import names [as 别名]
def accept_forwarding_with_successor(
context, predecessor_oguid, response_text, dossier=None):
# the predessecor (the forwarding on the remote client)
predecessor = Task.query.by_oguid(predecessor_oguid)
# Set the "X-CREATING-SUCCESSOR" flag for preventing the event handler
# from creating additional responses per added document.
context.REQUEST.set('X-CREATING-SUCCESSOR', True)
# transport the remote forwarding to the inbox or actual yearfolder
transporter = Transporter()
inbox = get_current_inbox(context)
if dossier:
yearfolder = get_current_yearfolder(inbox=inbox)
successor_forwarding = transporter.transport_from(
yearfolder, predecessor.admin_unit_id, predecessor.physical_path)
else:
successor_forwarding = transporter.transport_from(
inbox, predecessor.admin_unit_id, predecessor.physical_path)
# Replace the issuer with the current inbox
successor_forwarding.issuer = get_current_org_unit().inbox().id()
successor_tc = ISuccessorTaskController(successor_forwarding)
# copy documents and map the intids
doc_transporter = getUtility(ITaskDocumentsTransporter)
comment = _(
u'version_message_accept_forwarding',
default=u'Document copied from forwarding (forwarding accepted)')
intids_mapping = doc_transporter.copy_documents_from_remote_task(
predecessor, successor_forwarding, comment=comment)
# copy the responses
response_transporter = IResponseTransporter(successor_forwarding)
response_transporter.get_responses(predecessor.admin_unit_id,
predecessor.physical_path,
intids_mapping=intids_mapping)
# Remove current responsible from predecessor and add issuer
# and responsible to successor's watcher.
center = notification_center()
center.remove_task_responsible(Oguid.parse(predecessor_oguid),
successor_forwarding.responsible)
center.add_task_responsible(successor_forwarding,
successor_forwarding.responsible)
center.add_task_issuer(successor_forwarding, successor_forwarding.issuer)
# if a dossier is given means that a successor task must
# be created in a new or a existing dossier
if dossier:
# we need all task field values from the forwarding
fielddata = {}
for fieldname in ITask.names():
value = ITask.get(fieldname).get(successor_forwarding)
fielddata[fieldname] = value
# Predefine the task_type to avoid tasks with an invalid task_type
fielddata['task_type'] = FORWARDING_SUCCESSOR_TYPE
# lets create a new task - the successor task
task = createContentInContainer(
dossier, 'opengever.task.task', **fielddata)
# copy documents and map the intids
intids_mapping = _copy_documents_from_forwarding(
successor_forwarding, task)
# copy the responses
response_transporter = IResponseTransporter(task)
response_transporter.get_responses(
get_current_admin_unit().id(),
'/'.join(successor_forwarding.getPhysicalPath()),
intids_mapping=intids_mapping)
# successor
successor_tc_task = ISuccessorTaskController(task)
transaction.savepoint()
# Close the predessecor forwarding
response_text = response_text or ''
request_data = {'response_text': response_text.encode('utf-8'),
'successor_oguid': successor_tc.get_oguid(),
'transition': 'forwarding-transition-accept'}
response = dispatch_request(predecessor.admin_unit_id,
'@@store_forwarding_in_yearfolder',
path=predecessor.physical_path,
data=request_data)
response_body = response.read()
if response_body.strip() != 'OK':
raise TaskRemoteRequestError(
'Adding the response and changing the workflow state on the '
'predecessor forwarding failed.')
if dossier:
#.........这里部分代码省略.........