The upcoming version Plone 5.2 will support Plone 3, what does that mean for you?
When should you start to use Python 3 in your new Plone projects? When and how should you migrate existing projects to Python 3? How do you migrate addons and your custom code?
Drawing from the experience with the migration of Plone itself I'll answer all the questions that arise from moving to Python 3.
12. >>> text = u'foo'
>>> text
u'foo'
>>> text.encode('utf8')
'foo'
>>> text.decode('utf8')
u'foo'
Python 2: text
EXPLICIT CONVERSION
13. >>> text = 'foo'
>>> text
'foo'
>>> text.encode('utf8')
b'foo'
>>> text.decode('utf8')
AttributeError: 'str' object has no attribute
'decode'
Python 3: text
EXPLICIT CONVERSION
15. >>> [i for i in 'huhu']
['h', 'u', 'h', 'u']
Python 2
ITERATING OVER BYTES
16. >>> [i for i in b'huhu']
[104, 117, 104, 117]
>>> [chr(i) for i in b'huhu']
['h', 'u', 'h', 'u']
>>> [chr(i).encode('utf8') for i in b'huhu']
[b'h', b'u', b'h', b'u']
Python 3
ITERATING OVER BYTES
17. P Y T H O N 3 . 3
• Py3: u'text'
• Py2: b'bytes'
• u'text' is text in py2 and py3
• b'bytes' is bytes in py2 and py3
18. • text/bytes is the main issue when migrating code
• It makes much more sense in py3
• Writing code that works in py2/py3 is not easy
37. STEFFEN ALLNER | PHILIP BAUER | ROEL
BRUGGINK | GODEFROID CHAPELLE | MAIK
DERSTAPPEN | GIL FORCADA | HARALD
FRISENEGGER | DAVID GLICK | DANIEL
HAVLIK | MICHAEL HOWITZ | JENS KLEIN |
DAVI LIMA | ALEXANDER LOECHEL |
THOMAS LOTZE | PETER MATHIS | JAN
MEVISSEN | ROBERT NIEDERREITER | JONI
ORPONEN | ALESSANDRO PISA | JOHANNES
RAGGAM | MAURITS VAN REES | MANUEL
REINHARDT | THOMAS SCHORR | ERIC
STEELE | JENS VAGELPOHL | MATTHEW
WILKES | ANDI ZEIDLER
48. 1 . U P G R A D E T O P L O N E 5 . 2
• Use Python 2.7
49. 2 . D R O P A R C H E T Y P E S
• It's not asking too much
• Migration for default types is available since 2013
• Migration for custom types is available since 2015
50. 3 . M I G R AT E Y O U R C O D E T O P Y T H O N 3
• Without Database
• Support Python 2 and Python 3
• Small addons: Startup and fix whatever fails
• Bigger addons: Use python-modernize
• Same with tests
• Beware of complex doctests
51. 4 . M I G R AT E A D D O N S
• Same as above
• Everyone benefits
52. 5 . M I G R AT E Y O U R D ATA B A S E
• See David Glick's Talk
• Downtime/Read-only might be ineviable
53. 6 . D E P L O Y O N P Y T H O N 3
• Test the production-setup with WSGI early
67. W H Y D O E S N ' T T H E P L O N E
F O U N D AT I O N S I M P LY B U Y
S U P P O R T F O R P Y T H O N 2 . 7 F R O M
R E D H AT / I B M F O R A L L O F U S ?