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

martin.v.loewis python-checkins at python.org
Sat Oct 2 08:17:04 CEST 2010


Author: martin.v.loewis
Date: Sat Oct 2 08:17:03 2010
New Revision: 85159
Log:
Create django users and rietveld issues on creation
of respective roundup objects.
Added:
 tracker/instances/python-dev/detectors/rietveldreactor.py (contents, props changed)
Added: tracker/instances/python-dev/detectors/rietveldreactor.py
==============================================================================
--- (empty file)
+++ tracker/instances/python-dev/detectors/rietveldreactor.py	Sat Oct 2 08:17:03 2010
@@ -0,0 +1,29 @@
+import cPickle, base64
+
+# ListProperty is initialized to the cPickle of an empty list
+empty_list = base64.encodestring(cPickle.dumps([]))
+
+def create_django_user(db, cl, nodeid, oldvalues):
+ username = cl.get(nodeid, 'username')
+ email = cl.get(nodeid, 'address')
+ c = db.cursor
+ # django.contrib.auth.models.UNUSABLE_PASSWORD=='!'
+ c.execute("insert into auth_user(id, username, email, password, first_name, last_name, "
+ "is_staff, is_active, is_superuser, last_login, date_joined) "
+ "values(%s, %s, %s, '!', '', '', false, true, false, now(), now())",
+ (nodeid, username, email))
+
+def create_rietveld_issue(db, cl, nodeid, oldvalues):
+ subject = cl.get(nodeid, 'title')
+ c = db.cursor
+ # find owner id: same in django as in rietveld
+ owner_id = cl.get(nodeid, 'creator')
+ c.execute("insert into codereview_issue(id, subject, owner_id, reviewers, cc, created, modified, closed, private, n_comments) "
+ "values(%s, %s, %s, %s, %s, now(), now(), false, false, 0)",
+ (nodeid, subject, owner_id, empty_list, empty_list))
+
+def init(db):
+ db.user.react('create', create_django_user)
+ # XXX react to email changes, roles
+ db.issue.react('create', create_rietveld_issue)
+ # XXX reacto to subject, closed changes


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /