Permalink
Browse files

Switch to manual transaction management when voting on talks

Seems the automatic one works fine in dev, but not in production,
probably django version mismatch. Trying again with explicit manual
transaction management.
  • Loading branch information...
1 parent c124d85 commit fa2f47120b188e065d8cf275c0134ea3b6000980 @mhagander committed Apr 14, 2012
Showing with 15 additions and 14 deletions.
  1. +15 −14 postgresqleu/confreg/views.py
@@ -667,7 +667,6 @@ def __init__(self, session, n):
@login_required
-@transaction.commit_on_success
def talkvote(request, confname):
if settings.FORCE_SECURE_FORMS and not request.is_secure():
return HttpResponseRedirect(request.build_absolute_uri().replace('http://','https://',1))
@@ -683,19 +682,21 @@ def talkvote(request, confname):
# this code won't run often, so we don't really care about being
# fast, and this is easier...
# Thus, remove existing entries and replace them with current ones.
- curs.execute("DELETE FROM confreg_conferencesessionvote WHERE voter_id=%(userid)s AND session_id IN (SELECT id FROM confreg_conferencesession WHERE conference_id=%(confid)s)", {
- 'confid': conference.id,
- 'userid': request.user.id,
- })
- curs.executemany("INSERT INTO confreg_conferencesessionvote (session_id, voter_id, vote, comment) VALUES (%(sid)s, %(vid)s, %(vote)s, %(comment)s)", [
- {
- 'sid': k[3:],
- 'vid': request.user.id,
- 'vote': int(v) > 0 and int(v) or None,
- 'comment': request.POST['tc_%s' % k[3:]],
- }
- for k,v in request.POST.items() if k.startswith("sv_") and (int(v)>0 or request.POST['tc_%s' % k[3:]])
- ])
+ with transaction.commit_manually():
+ curs.execute("DELETE FROM confreg_conferencesessionvote WHERE voter_id=%(userid)s AND session_id IN (SELECT id FROM confreg_conferencesession WHERE conference_id=%(confid)s)", {
+ 'confid': conference.id,
+ 'userid': request.user.id,
+ })
+ curs.executemany("INSERT INTO confreg_conferencesessionvote (session_id, voter_id, vote, comment) VALUES (%(sid)s, %(vid)s, %(vote)s, %(comment)s)", [
+ {
+ 'sid': k[3:],
+ 'vid': request.user.id,
+ 'vote': int(v) > 0 and int(v) or None,
+ 'comment': request.POST['tc_%s' % k[3:]],
+ }
+ for k,v in request.POST.items() if k.startswith("sv_") and (int(v)>0 or request.POST['tc_%s' % k[3:]])
+ ])
+ transaction.commit()
return HttpResponseRedirect(".")
order = ""

0 comments on commit fa2f471

Please sign in to comment.