[Python-checkins] r88935 - tracker/instances/python-dev/detectors/rietveldreactor.py

martin.v.loewis python-checkins at python.org
Mon Apr 9 00:10:47 CEST 2012


Author: martin.v.loewis
Date: Mon Apr  9 00:10:47 2012
New Revision: 88935

Log:
Issue 402: Update Django auth_user.username when Roundup _username
changes.


Modified:
   tracker/instances/python-dev/detectors/rietveldreactor.py

Modified: tracker/instances/python-dev/detectors/rietveldreactor.py
==============================================================================
--- tracker/instances/python-dev/detectors/rietveldreactor.py	(original)
+++ tracker/instances/python-dev/detectors/rietveldreactor.py	Mon Apr  9 00:10:47 2012
@@ -15,6 +15,12 @@
               "values(%s, %s, %s, '!', '', '', false, true, false, now(), now())",
               (nodeid, username, email))
 
+def update_django_user(db, cl, nodeid, oldvalues):
+    if 'username' in oldvalues:
+        newname = cl.get(nodeid, 'username')
+        c = db.cursor
+        c.execute("update auth_user set username=%s where id=%s", (newname, nodeid))
+
 def update_issue_cc(db, cl, nodeid, oldvalues):
     if 'nosy' not in oldvalues:
         return
@@ -30,6 +36,7 @@
 
 def init(db):
     db.user.react('create', create_django_user)
+    db.user.react('set', update_django_user)
     db.issue.react('set', update_issue_cc)
     # XXX react to email changes, roles
     # XXX react to subject, closed changes on issues


More information about the Python-checkins mailing list