X-Git-Url: https://scm.cri.minesparis.psl.eu/git/Photo.git/blobdiff_plain/b0a7e10b4f32cf74864bb53268ca4d3080f23bc0..6c41809185e322ce2d30e98234f71144f78f06c0:/Products/Photo/migration/toblob.py diff --git a/Products/Photo/migration/toblob.py b/Products/Photo/migration/toblob.py new file mode 100755 index 0000000..ec4aec0 --- /dev/null +++ b/Products/Photo/migration/toblob.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +""" + + +Script de migration du stockage du fichier depuis l'attribut 'data' +vers l'attribut de type blob 'bdata'. +IMPORTANT : +les lignes 144 à 147 de blobbases.py doivent être commentéés +avant exécution. + +147 | # data = property(_getLegacyData, _setLegacyData, +148 | # "Data Legacy attribute to ensure compatibility " +149 | # "with derived classes that access data by this way.") + +""" + +from ZODB.blob import Blob + +def migrate(self) : + if hasattr(self.aq_base, 'data') : + data = str(self.data) + self.bdata = Blob() + bf = self.bdata.open('w') + bf.write(data) + bf.close() + delattr(self, 'data') + return True + else : + assert hasattr(self.aq_base, 'bdata') + return False + \ No newline at end of file