1 # -*- coding: utf-8 -*-
2 ############################################################
3 # Copyright © 2005-2008 Benoît PIN <benoit.pin@ensmp.fr> #
4 # Plinn - http://plinn.org #
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 ############################################################
12 from Products
.Portfolio
.container
import Portfolio
as NewPortfolio
13 from Products
.Portfolio
.photo
import Photo
as NewPhoto
15 IGNORED_ATTRIBUTES
= ('_randomCandidates', '_objects')
18 def migratePortfolio(old
, container
) :
19 print 'migrate %s' % old
.absolute_url()
24 new
= NewPortfolio(origid
, title
=title
)
26 for name
in old
.__dict
__.keys() :
27 if name
in IGNORED_ATTRIBUTES
:
30 setattr(new
, name
, getattr(old
, name
))
32 new
._populateFromFolder
(old
)
34 container
._delOb
(origid
)
35 container
._setOb
(origid
, new
)
37 return container
._getOb
(origid
)
39 def migratePhoto(old
, container
) :
40 print 'migrate %s' % old
.absolute_url()
45 new
= NewPhoto
.__new
__(NewPhoto
)
47 for name
in old
.__dict
__.keys() :
48 setattr(new
, name
, getattr(old
, name
))
50 container
._delOb
(origid
)
51 container
._setOb
(origid
, new
)
53 return container
._getOb
(origid
)