本文整理汇总了Python中corehq.form_processor.interfaces.processor.FormProcessorInterface.is_duplicate方法的典型用法代码示例。如果您正苦于以下问题:Python FormProcessorInterface.is_duplicate方法的具体用法?Python FormProcessorInterface.is_duplicate怎么用?Python FormProcessorInterface.is_duplicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.form_processor.interfaces.processor.FormProcessorInterface
的用法示例。
在下文中一共展示了FormProcessorInterface.is_duplicate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _handle_id_conflict
# 需要导入模块: from corehq.form_processor.interfaces.processor import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.processor.FormProcessorInterface import is_duplicate [as 别名]
def _handle_id_conflict(instance, xform, domain):
"""
For id conflicts, we check if the files contain exactly the same content,
If they do, we just log this as a dupe. If they don't, we deprecate the
previous form and overwrite it with the new form's contents.
"""
assert domain
conflict_id = xform.form_id
interface = FormProcessorInterface(domain)
if interface.is_duplicate(conflict_id, domain):
# It looks like a duplicate/edit in the same domain so pursue that workflow.
return _handle_duplicate(xform, instance)
else:
# the same form was submitted to two domains, or a form was submitted with
# an ID that belonged to a different doc type. these are likely developers
# manually testing or broken API users. just resubmit with a generated ID.
xform = interface.assign_new_id(xform)
return FormProcessingResult(xform)
示例2: _create_new_xform
# 需要导入模块: from corehq.form_processor.interfaces.processor import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.processor.FormProcessorInterface import is_duplicate [as 别名]
def _create_new_xform(domain, instance_xml, attachments=None):
"""
create but do not save an XFormInstance from an xform payload (xml_string)
optionally set the doc _id to a predefined value (_id)
return doc _id of the created doc
`process` is transformation to apply to the form right before saving
This is to avoid having to save multiple times
If xml_string is bad xml
- raise couchforms.XMLSyntaxError
:param domain:
"""
from corehq.form_processor.interfaces.processor import FormProcessorInterface
interface = FormProcessorInterface(domain)
assert attachments is not None
form_data = convert_xform_to_json(instance_xml)
if not form_data.get('@xmlns'):
raise MissingXMLNSError("Form is missing a required field: XMLNS")
adjust_datetimes(form_data)
xform = interface.new_xform(form_data)
xform.domain = domain
# Maps all attachments to uniform format and adds form.xml to list before storing
attachments = map(
lambda a: Attachment(name=a[0], raw_content=a[1], content_type=a[1].content_type),
attachments.items()
)
attachments.append(Attachment(name='form.xml', raw_content=instance_xml, content_type='text/xml'))
interface.store_attachments(xform, attachments)
result = LockedFormProcessingResult(xform)
with ReleaseOnError(result.lock):
if interface.is_duplicate(xform.form_id):
raise DuplicateError(xform)
return result