def resource_crud(request, slice_id, agg_id, resource_id = None):
    """
    Show a page that allows user to create/edit SampleResource's to the Aggregate.
    """
    slice = get_object_or_404(Slice, id = slice_id)
    aggregate = Aggregate.objects.get(id = agg_id)
    error_crud = ""

    def pre_save(instance, created):
        """
        Fills SampleResource instance prior to its saving.
        Used within the scope of the generic_crud method.
        """
        instance = SampleResourceController.fill(instance, slice, agg_id, resource_id)

    try:
        return generic_crud(request, obj_id=resource_id, model=SampleResourceModel,
                 form_class=SampleResourceModelForm,
                 template="sample_resource_resource_crud.html",
                 redirect=lambda inst: reverse("slice_detail", args=[slice_id]),
                 extra_context={"agg": aggregate, "slice": slice, "exception": error_crud, "breadcrumbs": (
                 ("Home", reverse("home")),
                 ("Project %s" % slice.project.name, reverse("project_detail", args=[slice.project.id])),
                 ("Slice %s" % slice.name, reverse("slice_detail", args=[slice_id])),
                 ("Update" % "%s SampleResource" if resource_id else "Create", reverse("sample_resource_resource_crud", args=[slice_id, agg_id])),)
                 }, extra_form_params={}, template_object_name="object", pre_save=pre_save,
                 post_save=None, success_msg=None)
    except ValidationError as e:
        # Django exception message handling is different to Python's...
        error_crud = ";".join(e.messages)
    except Exception as e:
        print "[WARNING] Could not create resource in plugin 'sample_resource'. Details: %s" % str(e)
        DatedMessage.objects.post_message_to_user(
            "SampleResource might have been created, but some problem ocurred: %s" % str(e),
            request.user, msg_type=DatedMessage.TYPE_ERROR)
        return HttpResponseRedirect(reverse("slice_detail", args=[slice_id]))
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/doc/plugins/samples/plugin/sample_resource/controller/GUIdispatcher.py/resource_crud/swapped operands of `%`