(request, crits_type, crits_id, preview)
Create the STIX document representing the given CRITs object.
    If preview, download the STIX file for user to peruse, else
    wrap in a TAXII message and send to TAXII server.

    :param request The request object
    :param crits_type The type of the crits object that will be converted
    :param crits_id The ID of the crits object that will be converted
    :param preview Boolean indicates if preview generation or message send req
Create the STIX document representing the given CRITs object.
    If preview, download the STIX file for user to peruse, else
    wrap in a TAXII message and send to TAXII server.
Create the STIX document representing the given CRITs object . If preview download the STIX file for user to peruse else wrap in a TAXII message and send to TAXII server .
def get_taxii_result(request, crits_type, crits_id, preview):
    """
    Create the STIX document representing the given CRITs object.
    If preview, download the STIX file for user to peruse, else
    wrap in a TAXII message and send to TAXII server.

    :param request The request object
    :param crits_type The type of the crits object that will be converted
    :param crits_id The ID of the crits object that will be converted
    :param preview Boolean indicates if preview generation or message send req
    """
    obj = class_from_id(crits_type, crits_id)
    if not obj:
        ret = {'success': False,
               'reason': "Could not locate object in the database."}
        return HttpResponse(json.dumps(ret), content_type="application/json")

    # did user accept responsibility for potential releasability updates?
    confirm_rel = True if "updates_confirmed" in request.POST else False

    form = forms.TAXIISendForm(request.user.username, obj, request.POST)
    if form.is_valid(): # ensures multiselect data was all in original form
        rcpts = form.cleaned_data.get('rcpts', [])
        relation_choices = form.get_chosen_relations()

        data = handlers.run_taxii_service(request.user.username, obj, rcpts,
                                          preview, relation_choices, confirm_rel)

        # if doing preview and data available, download as file
        if preview and data and 'preview' in data:
            resp = HttpResponse(data['preview'],
                                content_type="application/xml")
            utcnow = datetime.utcnow().strftime('%Y%m%dT%H%M%S')
            c_disp = 'attachment; filename="stix_preview-%s.xml"' % utcnow
            resp['Content-Disposition'] = c_disp
            return resp
        else: # else show success/error message that has been generated
            return HttpResponse(json.dumps(data), content_type="application/json")
    else: # form doesn't validate
        data = {'success': False,
                'reason': "Invalid options provided. Please fix and try again."}
        return HttpResponse(json.dumps(data), content_type="application/json")
def get_taxii_result ( request , crits_type , crits_id , preview ) : obj = class_from_id ( crits_type , crits_id ) if not obj : ret = { 'success' : False , 'reason' : "Could not locate object in the database." } return HttpResponse ( json . dumps ( ret ) , content_type = "application/json" ) # did user accept responsibility for potential releasability updates? confirm_rel = True if "updates_confirmed" in request . POST else False form = forms . TAXIISendForm ( request . user . username , obj , request . POST ) if form . is_valid ( ) : # ensures multiselect data was all in original form rcpts = form . cleaned_data . get ( 'rcpts' , [ ] ) relation_choices = form . get_chosen_relations ( ) data = handlers . run_taxii_service ( request . user . username , obj , rcpts , preview , relation_choices , confirm_rel ) # if doing preview and data available, download as file if preview and data and 'preview' in data : resp = HttpResponse ( data [ 'preview' ] , content_type = "application/xml" ) utcnow = datetime . utcnow ( ) . strftime ( '%Y%m%dT%H%M%S' ) c_disp = 'attachment; filename="stix_preview-%s.xml"' % utcnow resp [ 'Content-Disposition' ] = c_disp return resp else : # else show success/error message that has been generated return HttpResponse ( json . dumps ( data ) , content_type = "application/json" ) else : # form doesn't validate data = { 'success' : False , 'reason' : "Invalid options provided. Please fix and try again." } return HttpResponse ( json . dumps ( data ) , content_type = "application/json" )