mirror of
https://github.com/evennia/evennia.git
synced 2026-03-22 15:56:30 +01:00
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
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue