﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18080	@transaction.commit_manually plus context processors doesn't work well	jstpierre@…	nobody	"Imagine a view that looks like this:

{{{
    @transaction.commit_manually
    def create_new_foo(request):
        name = request.GET['name']
        obj = MyFoo(name=name)
        # We need to add the object to a ManyToMany
        # so we need a PK.
        obj.save()
        add_to_many_to_many(obj)
        if obj.is_valid():
            valid = True
            transaction.commit()
        else:
            valid = False
            transaction.rollback()

        return render_to_response(""objs/obj_created.html"", {'valid': valid,
                                                            'obj': obj})
}}}

Now imagine a context processor in another application entirely that looks like this:

{{{
    def num_my_bars(request):
        return MyBar.objects.count()
}}}

Since num_my_bars hits the database during the render, the transaction will be dirtied and leaving the commit_manually view will fail. A dirty solution may be to do:

{{{
        response = render_to_response(...)
        transaction.set_clean()
        return response
}}}

in the view, but this is dirty and awkward."	Uncategorized	closed	Uncategorized	1.3	Normal	invalid			Unreviewed	0	0	0	0	0	0
