Added some more error catching to the attr migrations.

This commit is contained in:
Griatch 2012-02-22 11:40:52 +01:00
parent a923a9a061
commit 440d403327
3 changed files with 41 additions and 30 deletions

View file

@ -152,17 +152,20 @@ class Migration(DataMigration):
def forwards(self, orm):
"Write your forwards methods here."
for attr in orm.ScriptAttribute.objects.all():
# repack attr into new format, and reimport
val = pickle.loads(to_str(attr.db_value))
if hasattr(val, '__iter__'):
val = ("iter", val)
elif type(val) == PackedDBobject:
val = ("dbobj", val)
else:
val = ("simple", val)
attr.db_value = to_unicode(pickle.dumps(to_str(to_attr(from_attr(attr, val)))))
attr.save()
try:
# repack attr into new format, and reimport
val = pickle.loads(to_str(attr.db_value))
if hasattr(val, '__iter__'):
val = ("iter", val)
elif type(val) == PackedDBobject:
val = ("dbobj", val)
else:
val = ("simple", val)
attr.db_value = to_unicode(pickle.dumps(to_str(to_attr(from_attr(attr, val)))))
attr.save()
except TypeError, RuntimeError:
pass
def backwards(self, orm):
"Write your backwards methods here."
raise RuntimeError