(domain, instance_xml, attachments=None, auth_context=None)
return FormProcessingResult(xform)
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:

    :returns: FormProcessingResult or raises an error
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
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
def _create_new_xform(domain, instance_xml, attachments=None, auth_context=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:

    :returns: FormProcessingResult or raises an error
    """
    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
    xform.auth_context = auth_context

    # Maps all attachments to uniform format and adds form.xml to list before storing
    attachments = [Attachment(name=a[0], raw_content=a[1], content_type=a[1].content_type) for a in attachments.items()]
    attachments.append(Attachment(name='form.xml', raw_content=instance_xml, content_type='text/xml'))
    interface.store_attachments(xform, attachments)

    assert xform.is_normal
    return FormProcessingResult(xform)
def _create_new_xform ( domain , instance_xml , attachments = None , auth_context = None ) : 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 xform . auth_context = auth_context # Maps all attachments to uniform format and adds form.xml to list before storing attachments = [ Attachment ( name = a [ 0 ] , raw_content = a [ 1 ] , content_type = a [ 1 ] . content_type ) for a in attachments . items ( ) ] attachments . append ( Attachment ( name = 'form.xml' , raw_content = instance_xml , content_type = 'text/xml' ) ) interface . store_attachments ( xform , attachments ) assert xform . is_normal return FormProcessingResult ( xform )