def generic_crud(request, obj_id, model, template, redirect,
                 extra_context={}, form_class=None,
                 template_object_name="object", pre_save=None,
                 post_save=None, success_msg=None):
    
    model, form_class = get_model_and_form_class(model, form_class)

    if obj_id != None:
        instance = get_object_or_404(model, pk=obj_id)
    else:
        instance = None
        
    if request.method == "GET":
        form = form_class(instance=instance)
    elif request.method == "POST":
        form = form_class(request.POST, instance=instance)
        if form.is_valid():
            instance = form.save(commit=False)
            if pre_save: pre_save(instance, obj_id == None)
            instance.save()
            if post_save: post_save(instance, obj_id == None)
            form.save_m2m()
            if success_msg:
                DatedMessage.objects.post_message_to_user(
                    success_msg(instance), request.user,
                    msg_type=DatedMessage.TYPE_SUCCESS)
            return HttpResponseRedirect(redirect(instance))
    else:
        return HttpResponseNotAllowed("GET", "POST")

    context = {"form": form}
    context.update(extra_context)
    if obj_id != None: context[template_object_name] = instance

    return simple.direct_to_template(
        request,
        template=template,
        extra_context=context,
        form=form,
    )
Create a new hashing object and return it.
dataset/ETHPy150Open fp7-ofelia/ocf/vt_manager/src/python/vt_manager/common/utils/views.py/generic_crud--crossover with--dataset/ETHPy150Open CollabQ/CollabQ/vendor/gdata/tlslite/utils/hmac.py/new