]> CRI, Mines Paris - PSL - Photo.git/blobdiff - Products/Photo/migration/from2to3.py
eggification
[Photo.git] / Products / Photo / migration / from2to3.py
diff --git a/Products/Photo/migration/from2to3.py b/Products/Photo/migration/from2to3.py
new file mode 100644 (file)
index 0000000..13882ca
--- /dev/null
@@ -0,0 +1,30 @@
+from BTrees.OOBTree import OOBTree
+from BTrees.IOBTree import IOBTree
+
+def migrate(p) :
+       if hasattr(p, '_variants') :
+               delattr(p, '_variants')
+       
+       if not hasattr(p, 'tiles_available') :
+               p.tiles_available = 0
+       
+       
+       if hasattr(p, '_methodResultsCache') and p._methodResultsCache.has_key('_getTile'):
+               p._tiles = OOBTree()
+               for args, value in p._methodResultsCache['_getTile'].items() :
+                       args = dict(args)
+                       zoom = float(args['zoom'])
+                       x = int(args['x'])
+                       y = int(args['y'])
+
+                       if not p._tiles.has_key(zoom) :
+                               p._tiles[zoom] = IOBTree()
+                       if not p._tiles[zoom].has_key(x) :
+                               p._tiles[zoom][x] = IOBTree()
+                       
+                       p._tiles[zoom][x][y] = value
+               del p._methodResultsCache['_getTile']
+               
+       elif not hasattr(p, '_tiles'):
+               p._tiles = OOBTree()
+               p.tiles_available = 0