Added some more error catching to the attr migrations.
This commit is contained in:
parent
a923a9a061
commit
440d403327
3 changed files with 41 additions and 30 deletions
|
|
@ -151,17 +151,21 @@ class Migration(DataMigration):
|
||||||
|
|
||||||
def forwards(self, orm):
|
def forwards(self, orm):
|
||||||
"Write your forwards methods here."
|
"Write your forwards methods here."
|
||||||
|
|
||||||
for attr in orm.ObjAttribute.objects.all():
|
for attr in orm.ObjAttribute.objects.all():
|
||||||
# repack attr into new format, and reimport
|
# repack attr into new format, and reimport
|
||||||
val = pickle.loads(to_str(attr.db_value))
|
try:
|
||||||
if hasattr(val, '__iter__'):
|
val = pickle.loads(to_str(attr.db_value))
|
||||||
val = ("iter", val)
|
if hasattr(val, '__iter__'):
|
||||||
elif type(val) == PackedDBobject:
|
val = ("iter", val)
|
||||||
val = ("dbobj", val)
|
elif type(val) == PackedDBobject:
|
||||||
else:
|
val = ("dbobj", val)
|
||||||
val = ("simple", val)
|
else:
|
||||||
attr.db_value = to_unicode(pickle.dumps(to_str(to_attr(from_attr(attr, val)))))
|
val = ("simple", val)
|
||||||
attr.save()
|
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):
|
def backwards(self, orm):
|
||||||
"Write your backwards methods here."
|
"Write your backwards methods here."
|
||||||
|
|
|
||||||
|
|
@ -154,16 +154,20 @@ class Migration(DataMigration):
|
||||||
def forwards(self, orm):
|
def forwards(self, orm):
|
||||||
"Write your forwards methods here."
|
"Write your forwards methods here."
|
||||||
for attr in orm.PlayerAttribute.objects.all():
|
for attr in orm.PlayerAttribute.objects.all():
|
||||||
# repack attr into new format, and reimport
|
try:
|
||||||
val = pickle.loads(to_str(attr.db_value))
|
# repack attr into new format, and reimport
|
||||||
if hasattr(val, '__iter__'):
|
val = pickle.loads(to_str(attr.db_value))
|
||||||
val = ("iter", val)
|
if hasattr(val, '__iter__'):
|
||||||
elif type(val) == PackedDBobject:
|
val = ("iter", val)
|
||||||
val = ("dbobj", val)
|
elif type(val) == PackedDBobject:
|
||||||
else:
|
val = ("dbobj", val)
|
||||||
val = ("simple", val)
|
else:
|
||||||
attr.db_value = to_unicode(pickle.dumps(to_str(to_attr(from_attr(attr, val)))))
|
val = ("simple", val)
|
||||||
attr.save()
|
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):
|
def backwards(self, orm):
|
||||||
"Write your backwards methods here."
|
"Write your backwards methods here."
|
||||||
|
|
|
||||||
|
|
@ -152,17 +152,20 @@ class Migration(DataMigration):
|
||||||
def forwards(self, orm):
|
def forwards(self, orm):
|
||||||
"Write your forwards methods here."
|
"Write your forwards methods here."
|
||||||
for attr in orm.ScriptAttribute.objects.all():
|
for attr in orm.ScriptAttribute.objects.all():
|
||||||
# repack attr into new format, and reimport
|
try:
|
||||||
val = pickle.loads(to_str(attr.db_value))
|
# repack attr into new format, and reimport
|
||||||
if hasattr(val, '__iter__'):
|
val = pickle.loads(to_str(attr.db_value))
|
||||||
val = ("iter", val)
|
if hasattr(val, '__iter__'):
|
||||||
elif type(val) == PackedDBobject:
|
val = ("iter", val)
|
||||||
val = ("dbobj", val)
|
elif type(val) == PackedDBobject:
|
||||||
else:
|
val = ("dbobj", val)
|
||||||
val = ("simple", val)
|
else:
|
||||||
attr.db_value = to_unicode(pickle.dumps(to_str(to_attr(from_attr(attr, val)))))
|
val = ("simple", val)
|
||||||
attr.save()
|
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):
|
def backwards(self, orm):
|
||||||
"Write your backwards methods here."
|
"Write your backwards methods here."
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue