Création macro « thumbnails » qui ne comprend que les slides.
[Portfolio.git] / migration / toV3.py
1 # -*- coding: utf-8 -*-
2 ############################################################
3 # Copyright © 2005-2008 Benoît PIN <benoit.pin@ensmp.fr> #
4 # Plinn - http://plinn.org #
5 # #
6 # This program is free software; you can redistribute it #
7 # and/or modify it under the terms of the Creative Commons #
8 # "Attribution-Noncommercial 2.0 Generic" #
9 # http://creativecommons.org/licenses/by-nc/2.0/ #
10 ############################################################
11
12 from Products.Portfolio.container import Portfolio as NewPortfolio
13 from Products.Portfolio.photo import Photo as NewPhoto
14
15 IGNORED_ATTRIBUTES = ('_randomCandidates', '_objects')
16
17
18 def migratePortfolio(old, container) :
19 print 'migrate %s' % old.absolute_url()
20
21 origid = old.getId()
22 title = old.Title()
23
24 new = NewPortfolio(origid, title=title)
25
26 for name in old.__dict__.keys() :
27 if name in IGNORED_ATTRIBUTES :
28 continue
29 else :
30 setattr(new, name, getattr(old, name))
31
32 new._populateFromFolder(old)
33
34 container._delOb(origid)
35 container._setOb(origid, new)
36
37 return container._getOb(origid)
38
39 def migratePhoto(old, container) :
40 print 'migrate %s' % old.absolute_url()
41
42 origid = old.getId()
43 title = old.Title()
44
45 new = NewPhoto.__new__(NewPhoto)
46
47 for name in old.__dict__.keys() :
48 setattr(new, name, getattr(old, name))
49
50 container._delOb(origid)
51 container._setOb(origid, new)
52
53 return container._getOb(origid)