[damned-lies] Fix and improve openid lib migration
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Fix and improve openid lib migration
- Date: Tue, 19 Apr 2011 16:24:30 +0000 (UTC)
commit 6aada3bda141c5b37cc1b8348cb0061a445ef8be
Author: Claude Paroz <claude 2xlibre net>
Date: Tue Apr 19 18:24:16 2011 +0200
Fix and improve openid lib migration
common/migrations/0001_openid_migration.py | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/common/migrations/0001_openid_migration.py b/common/migrations/0001_openid_migration.py
index e7f6943..535c338 100644
--- a/common/migrations/0001_openid_migration.py
+++ b/common/migrations/0001_openid_migration.py
@@ -3,6 +3,7 @@ import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
+from django.db.utils import IntegrityError
class Migration(DataMigration):
@@ -13,14 +14,17 @@ class Migration(DataMigration):
from django_openid_auth import models as new_models
except ImportError:
# skip migration
- pass # return
- import pdb; pdb.set_trace()
- """for nonce in models.Nonce.objects.all():
+ print "Either old django_openid or new django_openid_auth is absent. Skipping migration."
+ return
+ for nonce in models.Nonce.objects.all():
new_nonce = new_models.Nonce.objects.create(server_url=nonce.server_url, timestamp=nonce.timestamp, salt=nonce.salt)
for assoc in models.Association.objects.all():
- new_assoc = new_models.Association.objects.create(server_url=assoc.server_url, handle=assoc.handle, secret=assoc.secret, issued=assoc.issued, lifetime=assoc.lifetime, assoc_type=assoc.assoc_type)"""
+ new_assoc = new_models.Association.objects.create(server_url=assoc.server_url, handle=assoc.handle, secret=assoc.secret, issued=assoc.issued, lifetime=assoc.lifetime, assoc_type=assoc.assoc_type)
for user_assoc in models.UserOpenidAssociation.objects.all():
- new_uassoc = new_models.UserOpenID.objects.create(user=user_assoc.user, claimed_id=user_assoc.openid, display_id=user_assoc.openid)
+ try:
+ new_uassoc = new_models.UserOpenID.objects.create(user=user_assoc.user, claimed_id=user_assoc.openid, display_id=user_assoc.openid)
+ except IntegrityError:
+ pass
def backwards(self, orm):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]