]> CRI, Mines Paris - PSL - Photo.git/blobdiff - Products/Photo/migration/toblob.py
eggification
[Photo.git] / Products / Photo / migration / toblob.py
diff --git a/Products/Photo/migration/toblob.py b/Products/Photo/migration/toblob.py
new file mode 100755 (executable)
index 0000000..ec4aec0
--- /dev/null
@@ -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