eggification
[Photo.git] / Products / Photo / migration / from2to3.py
1 from BTrees.OOBTree import OOBTree
2 from BTrees.IOBTree import IOBTree
3
4 def migrate(p) :
5 if hasattr(p, '_variants') :
6 delattr(p, '_variants')
7
8 if not hasattr(p, 'tiles_available') :
9 p.tiles_available = 0
10
11
12 if hasattr(p, '_methodResultsCache') and p._methodResultsCache.has_key('_getTile'):
13 p._tiles = OOBTree()
14 for args, value in p._methodResultsCache['_getTile'].items() :
15 args = dict(args)
16 zoom = float(args['zoom'])
17 x = int(args['x'])
18 y = int(args['y'])
19
20 if not p._tiles.has_key(zoom) :
21 p._tiles[zoom] = IOBTree()
22 if not p._tiles[zoom].has_key(x) :
23 p._tiles[zoom][x] = IOBTree()
24
25 p._tiles[zoom][x][y] = value
26 del p._methodResultsCache['_getTile']
27
28 elif not hasattr(p, '_tiles'):
29 p._tiles = OOBTree()
30 p.tiles_available = 0