X-Git-Url: https://scm.cri.minesparis.psl.eu/git/Photo.git/blobdiff_plain/b0a7e10b4f32cf74864bb53268ca4d3080f23bc0..6c41809185e322ce2d30e98234f71144f78f06c0:/Products/Photo/migration/from2to3.py diff --git a/Products/Photo/migration/from2to3.py b/Products/Photo/migration/from2to3.py new file mode 100644 index 0000000..13882ca --- /dev/null +++ b/Products/Photo/migration/from2to3.py @@ -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