Created
January 12, 2011 04:39
-
-
Save skyl/775697 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@transaction.commit_on_success | |
def _action(action, o): | |
getattr(o,action)() | |
o.is_processing = False | |
o.save() | |
def _bulk_action(action, objs): | |
for o in objs: | |
_action(action,o) | |
def bulk_action(request, t): | |
... | |
objs = model.objects.filter(pk__in=pks) | |
if request.method == 'POST': | |
objs.update(is_processing=True) | |
from multiprocessing import Process | |
p = Process(target=_bulk_action,args=(action,objs)) | |
p.start() | |
return HttpResponseRedirect(next_url) | |
context = {'t': t, 'action': action, 'objs': objs, 'model': model} | |
return render_to_response(...) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment