SlideShare a Scribd company logo
Doing the Impossible
Porting RestrictedPython to Python 3

The way to Python 3 for Plone?
Alexander Loechel

PloneConf 2017 - Barcelona
1
–Johnny Appleseed
“Type a quote here.”
2
End of Life
for Python 2
by 2020 PyCon
(April 12th 2020)
PloneConf 2014 Bristol - Plone Roadmap Discussion
“Plone on Python 3 

is impossible,
there are too 

many blockers in Zope.
Especially RestrictedPython
& AccessControl”
3
Clarke's First Law – Arthur C. Clarke
“When a distinguished but elderly
scientist states that something is
possible, he is almost certainly right. 

When he states that something is
impossible, he is very probably wrong.”
4
– 2015 - Start looking into RestrictedPython
“Why should RestrictedPython
be the major blocker for 

Plone on Python 3?”
5
Hanno Schlichting - Zope Release Manager
„Every piece of Zope that was not
adopted by Plone is literally dead.“
6
„Debugging is twice as hard as writing
the code in the first place. Therefore, if
you write the code as cleverly as
possible, you are, by definition, not
smart enough to debug it.“
7
- Brian Kernighan
Almost no documentation
low test coverage
Python community - around 2000
„Where Zope leads,
Python follows“
8
Zope specific leftovers in the Python 2 Standard Library
Deprecated Python Standard Library Modules:

• compiler Package (no described upgrade path, almost no documentation)
Clarke's Second Law – Arthur C. Clarke
“The only way of discovering the
limits of the possible is to
venture a little way past them
into the impossible.”
9
Clarke's Third Law – Arthur C. Clarke
“Any sufficiently 

advanced technology 

is indistinguishable 

from magic.”
10
• TTW (Through-The-Web)

• PythonScripts

• DocumentTemplate

• Workflows

• Zope ZCatalog
11
What is
RestrictedPython
and what is it not?
12
A Workshop on Python at NIST

SPAM 1 - First PyCon (1994) - Topics
I've assembled a strawman list of topics for discussion. New topics

and comments on the topics listed are certainly welcome.
A.Requirements for a "Safe" Python interpreter
B. A standard GUI module interface definition for Python
C.The requirements for persistent objects in Python
D.A Python engineering graphs package
E. The standard Python WWW interface
F. Embedding Python in a WWW client
G.Technical information management using Python
H.Support for dynamic loading of foreign language modules in Python
I. Replacing make, rcs, and cvs with Python
J. An Electronic Data Interchange library for Python
K. Discussing the formation of a Python Consortium
13
Rich Hickey
“Most of the biggest problem 

in software are problems of
misconception.”
14
No Sandbox
Sandboxes most often don’t work
15
Limited, „Safe“ Subset
of the Python Programming
Language / Grammar
• No more Turing Complete
• Common Technique (Ada RavenScar Profile)
16
The Way to 

RestrictedPython 4.0

and Python 3
17
- John Johnson
“First, solve the problem.
Then, write the code.”
18
• Python 2 Standard Library Module compiler and its Class ast

• Not fully documented

• No upgrade path for Python 3 described

• manual Byte-Code generator

• Interpreter specifics —> Only CPython 2 compatible
19
If it is not documented it is not usable

if it is not tested it did not work

if it is not checked into version control it did not exists

if it is not repeatable it is not science
• Compiler knowledge was necessary to port RestrictedPython

• I did have a degree in Informatics (Computer Science) and 

learned how to build and manipulate compilers, so give it a try.
20
Plone Open Garden 2015
Start looking into RestrictedPython
21
Kent Beck
“Any fool can write code that a
computer can understand.
Good programmers write code
that humans can understand.”
22
Reading & 

understanding the Code
Louis Sreygley
“Without requirements or design,
programming is the art of adding
bugs to an empty text file.”
23
Documentation First +
Test Driven Development
• compiler.ast => ast.AST

• builtin compile() function since Python 2.6 accepts ast.AST as input
and compiles to Python Byte-Code —> Interpreter independence

• compile(source, filename, mode [, flags=ast.PyCF_ONLY_AST [, dont_inherit]]) 

or ast.parse() return ast.AST
With Python 2.6+ / 3.4+ RestrictedPython could be easier to implement
24
Got Access to Zope Foundation Repositories via Tres Seaver at Plone Symposium Tokyo 2015
“Access Required.”
25
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to
break the rules.
…
PEP 20 - 19. Aug. 2004 https://www.python.org/dev/peps/pep-0020/
26
Apply Python’s PEP8 and
Plone’s Coding Conventions
—> Make the Code more readable
– Richard Feynman
“The first principle is that you
must not fool yourself — and you
are the easiest person to fool.”
27
Writing Tests & raising test coverage
—> Functional Test of all Python Syntax cases
tox & .
• tox: local tests of multiple python versions

• pytest: modern Python testing framework, that allows:

• parameterisation (inputs and functions)

• skip_if
• assert 

Talk: Modern Python Testing
28
Test example (pytest)
c_exec = (c_exec‘, [ 

RestrictedPython.compile.compile_restricted_exec,

RestrictedPython.RCompile.compile_restricted_exec,

])
@pytest.mark.parametrize(*c_exec)
def test_(c_exec):
result = c_exec('a = max([1, 2, 3])')

assert result.errors == ()
loc = {}
exec(result.code, {}, loc)
assert loc['a'] == 3
assert result.used_names == {'max': True}
29
Alpine City Sprint 2016 / 2017
Join in of Gocept & other Zope Core Developers
30
Ian Hickson
„Things that are impossible

just take longer.“
31
May 2017 Release of RestrictedPython 4.0a1
https://pypi.python.org/pypi/RestrictedPython —> 4.0.b2
Welcome to the Python 3 Wonderland32
Philip J. Eby - Python Core Developer - Author PEP 333/3333 - WSGI
„Those who do not study Zope,
are condemned to reinvent it.“
33
Bjarne Stroustrup
“If you think it’s simple, 

then you have 

misunderstood the problem.”
34
My Wish
Make RestrictedPython more known
enable other Projects and Frameworks to use 

a „Safe“ Python Interpreter through the Web
John Gall - Systemantics: How Systems Really Work and How They Fail
A complex system that works is invariably

found to have evolved from a simple system

that worked. A complex system designed from scratch
never works and cannot be patched up to make it work. 

You have to start over with a working simple system.
36
Lessons Learned while Porting RestrictedPython
• Don’t take »„impossible“ to port / fix« statements serious

• Adopt modern tools and frameworks that helps:

• tox & pytest

—> Update Best Practices for Plone development
37
Some further Talk recommendations
• Zope on Python 3

Hanno Schlichting - Friday 14:30-15:15 - Auditori

• Modern Python Testing

Alexander Loechel - Thursday 14:30-15:15 - Sala d'actes

• subtemplates in bobtemplates.plone or on the way to plonecli 

Maik Derstappen - Friday 15:25-15:55 - Sala d'actes
38
Clarke's Law of Revolutionary Ideas – Arthur C. Clarke
Every revolutionary idea 

— in science, politics, art, or whatever — 

seems to evoke three stages of reaction. 

They may be summed up by the phrases:
1. "It's completely impossible — don't waste my time"
2. "It's possible, but it's not worth doing"
3. "I said it was a good idea all along"
39

More Related Content

What's hot

TDD and the Legacy Code Black Hole
TDD and the Legacy Code Black HoleTDD and the Legacy Code Black Hole
TDD and the Legacy Code Black Hole
Noam Kfir
 
Test Driven Development With Python
Test Driven Development With PythonTest Driven Development With Python
Test Driven Development With Python
Siddhi
 
Applying TDD to Legacy Code
Applying TDD to Legacy CodeApplying TDD to Legacy Code
Applying TDD to Legacy Code
Alexander Goida
 
Unit Testing RPG with JUnit
Unit Testing RPG with JUnitUnit Testing RPG with JUnit
Unit Testing RPG with JUnitGreg.Helton
 
Communication between Java and Python
Communication between Java and PythonCommunication between Java and Python
Communication between Java and Python
Andreas Schreiber
 
TDD in Python With Pytest
TDD in Python With PytestTDD in Python With Pytest
TDD in Python With Pytest
Eddy Reyes
 
Plone Testing Tools And Techniques
Plone Testing Tools And TechniquesPlone Testing Tools And Techniques
Plone Testing Tools And Techniques
Jordan Baker
 
Plone testingdzug tagung2010
Plone testingdzug tagung2010Plone testingdzug tagung2010
Plone testingdzug tagung2010Timo Stollenwerk
 
web programming Unit VIII complete about python by Bhavsingh Maloth
web programming Unit VIII complete about python  by Bhavsingh Malothweb programming Unit VIII complete about python  by Bhavsingh Maloth
web programming Unit VIII complete about python by Bhavsingh Maloth
Bhavsingh Maloth
 
Python-nose: A unittest-based testing framework for Python that makes writing...
Python-nose: A unittest-based testing framework for Python that makes writing...Python-nose: A unittest-based testing framework for Python that makes writing...
Python-nose: A unittest-based testing framework for Python that makes writing...
Timo Stollenwerk
 
Introduzione al TDD
Introduzione al TDDIntroduzione al TDD
Introduzione al TDD
Andrea Francia
 
Cursus phpunit
Cursus phpunitCursus phpunit
Cursus phpunit
Nick Belhomme
 
Scryent: Plone - Hone Your Test Fu
Scryent: Plone - Hone Your Test FuScryent: Plone - Hone Your Test Fu
Scryent: Plone - Hone Your Test Fu
Jordan Baker
 
Interpreter RPG to Java
Interpreter RPG to JavaInterpreter RPG to Java
Interpreter RPG to Java
farerobe
 
What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.
Mark Rees
 
Google mock for dummies
Google mock for dummiesGoogle mock for dummies
Google mock for dummies
Harry Potter
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answers
ITeLearn
 
Sour Pickles
Sour PicklesSour Pickles
Sour Pickles
SensePost
 

What's hot (19)

TDD and the Legacy Code Black Hole
TDD and the Legacy Code Black HoleTDD and the Legacy Code Black Hole
TDD and the Legacy Code Black Hole
 
Test Driven Development With Python
Test Driven Development With PythonTest Driven Development With Python
Test Driven Development With Python
 
Applying TDD to Legacy Code
Applying TDD to Legacy CodeApplying TDD to Legacy Code
Applying TDD to Legacy Code
 
Unit Testing RPG with JUnit
Unit Testing RPG with JUnitUnit Testing RPG with JUnit
Unit Testing RPG with JUnit
 
Communication between Java and Python
Communication between Java and PythonCommunication between Java and Python
Communication between Java and Python
 
TDD in Python With Pytest
TDD in Python With PytestTDD in Python With Pytest
TDD in Python With Pytest
 
Plone Testing Tools And Techniques
Plone Testing Tools And TechniquesPlone Testing Tools And Techniques
Plone Testing Tools And Techniques
 
Plone testingdzug tagung2010
Plone testingdzug tagung2010Plone testingdzug tagung2010
Plone testingdzug tagung2010
 
Pyunit
PyunitPyunit
Pyunit
 
web programming Unit VIII complete about python by Bhavsingh Maloth
web programming Unit VIII complete about python  by Bhavsingh Malothweb programming Unit VIII complete about python  by Bhavsingh Maloth
web programming Unit VIII complete about python by Bhavsingh Maloth
 
Python-nose: A unittest-based testing framework for Python that makes writing...
Python-nose: A unittest-based testing framework for Python that makes writing...Python-nose: A unittest-based testing framework for Python that makes writing...
Python-nose: A unittest-based testing framework for Python that makes writing...
 
Introduzione al TDD
Introduzione al TDDIntroduzione al TDD
Introduzione al TDD
 
Cursus phpunit
Cursus phpunitCursus phpunit
Cursus phpunit
 
Scryent: Plone - Hone Your Test Fu
Scryent: Plone - Hone Your Test FuScryent: Plone - Hone Your Test Fu
Scryent: Plone - Hone Your Test Fu
 
Interpreter RPG to Java
Interpreter RPG to JavaInterpreter RPG to Java
Interpreter RPG to Java
 
What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.
 
Google mock for dummies
Google mock for dummiesGoogle mock for dummies
Google mock for dummies
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answers
 
Sour Pickles
Sour PicklesSour Pickles
Sour Pickles
 

Similar to Doing the Impossible

05 python.pdf
05 python.pdf05 python.pdf
05 python.pdf
SugumarSarDurai
 
Python Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech PunePython Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech Pune
Ethan's Tech
 
Python @ PiTech - March 2009
Python @ PiTech - March 2009Python @ PiTech - March 2009
Python @ PiTech - March 2009tudorprodan
 
Python intro
Python introPython intro
Python intro
rik0
 
PyCon2022 - Building Python Extensions
PyCon2022 - Building Python ExtensionsPyCon2022 - Building Python Extensions
PyCon2022 - Building Python Extensions
Henry Schreiner
 
Introduction to python 3 2nd round
Introduction to python 3   2nd roundIntroduction to python 3   2nd round
Introduction to python 3 2nd round
Youhei Sakurai
 
pycon-2015-liza-daly
pycon-2015-liza-dalypycon-2015-liza-daly
pycon-2015-liza-dalyLiza Daly
 
Python Programming1.ppt
Python Programming1.pptPython Programming1.ppt
Python Programming1.ppt
Rehnawilson1
 
python into.pptx
python into.pptxpython into.pptx
python into.pptx
Punithavel Ramani
 
Introduction to python 3
Introduction to python 3Introduction to python 3
Introduction to python 3
Youhei Sakurai
 
Python 3.5: An agile, general-purpose development language.
Python 3.5: An agile, general-purpose development language.Python 3.5: An agile, general-purpose development language.
Python 3.5: An agile, general-purpose development language.
Carlos Miguel Ferreira
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
Shivam Gupta
 
Python
PythonPython
Python
Shivam Gupta
 
python-160403194316.pdf
python-160403194316.pdfpython-160403194316.pdf
python-160403194316.pdf
gmadhu8
 
Plone - A History of Python Web
Plone - A History of Python WebPlone - A History of Python Web
Plone - A History of Python Web
Alexander Loechel
 
Py4 inf 01-intro
Py4 inf 01-introPy4 inf 01-intro
Py4 inf 01-intro
Ishaq Ali
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
DrMohammed Qassim
 
Why Python Should Be Your First Programming Language
Why Python Should Be Your First Programming LanguageWhy Python Should Be Your First Programming Language
Why Python Should Be Your First Programming Language
Edureka!
 
Pythonic doesn't mean slow!
Pythonic doesn't mean slow!Pythonic doesn't mean slow!
Pythonic doesn't mean slow!
Ronan Lamy
 

Similar to Doing the Impossible (20)

05 python.pdf
05 python.pdf05 python.pdf
05 python.pdf
 
Python
PythonPython
Python
 
Python Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech PunePython Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech Pune
 
Python @ PiTech - March 2009
Python @ PiTech - March 2009Python @ PiTech - March 2009
Python @ PiTech - March 2009
 
Python intro
Python introPython intro
Python intro
 
PyCon2022 - Building Python Extensions
PyCon2022 - Building Python ExtensionsPyCon2022 - Building Python Extensions
PyCon2022 - Building Python Extensions
 
Introduction to python 3 2nd round
Introduction to python 3   2nd roundIntroduction to python 3   2nd round
Introduction to python 3 2nd round
 
pycon-2015-liza-daly
pycon-2015-liza-dalypycon-2015-liza-daly
pycon-2015-liza-daly
 
Python Programming1.ppt
Python Programming1.pptPython Programming1.ppt
Python Programming1.ppt
 
python into.pptx
python into.pptxpython into.pptx
python into.pptx
 
Introduction to python 3
Introduction to python 3Introduction to python 3
Introduction to python 3
 
Python 3.5: An agile, general-purpose development language.
Python 3.5: An agile, general-purpose development language.Python 3.5: An agile, general-purpose development language.
Python 3.5: An agile, general-purpose development language.
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
 
Python
PythonPython
Python
 
python-160403194316.pdf
python-160403194316.pdfpython-160403194316.pdf
python-160403194316.pdf
 
Plone - A History of Python Web
Plone - A History of Python WebPlone - A History of Python Web
Plone - A History of Python Web
 
Py4 inf 01-intro
Py4 inf 01-introPy4 inf 01-intro
Py4 inf 01-intro
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Why Python Should Be Your First Programming Language
Why Python Should Be Your First Programming LanguageWhy Python Should Be Your First Programming Language
Why Python Should Be Your First Programming Language
 
Pythonic doesn't mean slow!
Pythonic doesn't mean slow!Pythonic doesn't mean slow!
Pythonic doesn't mean slow!
 

More from Alexander Loechel

Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...
Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...
Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...
Alexander Loechel
 
The Plone is dead, long live the Plone!
The Plone is dead, long live the Plone!The Plone is dead, long live the Plone!
The Plone is dead, long live the Plone!
Alexander Loechel
 
We are the Plone Collective. Resistance is futile. Assimilation is inevitable.
We are the Plone Collective. Resistance is futile. Assimilation is inevitable.We are the Plone Collective. Resistance is futile. Assimilation is inevitable.
We are the Plone Collective. Resistance is futile. Assimilation is inevitable.
Alexander Loechel
 
Plone.org Improvements - Plone Addon Listing
Plone.org Improvements - Plone Addon ListingPlone.org Improvements - Plone Addon Listing
Plone.org Improvements - Plone Addon Listing
Alexander Loechel
 
Plone, quo vadis?
Plone, quo vadis?Plone, quo vadis?
Plone, quo vadis?
Alexander Loechel
 
Sphinx options to make training documentation easier to understand
Sphinx options to make training documentation easier to understandSphinx options to make training documentation easier to understand
Sphinx options to make training documentation easier to understand
Alexander Loechel
 
Web Content-Management-Systeme the Past - the Present - the Future
Web Content-Management-Systeme the Past - the Present - the FutureWeb Content-Management-Systeme the Past - the Present - the Future
Web Content-Management-Systeme the Past - the Present - the Future
Alexander Loechel
 
Plone, the Python CMS & Web Framework for Advanced Topics and Non-Developers
Plone, the Python CMS & Web Framework for Advanced Topics and Non-DevelopersPlone, the Python CMS & Web Framework for Advanced Topics and Non-Developers
Plone, the Python CMS & Web Framework for Advanced Topics and Non-Developers
Alexander Loechel
 
Plone im Kontext des WCMS Marktes
Plone im Kontext des WCMS MarktesPlone im Kontext des WCMS Marktes
Plone im Kontext des WCMS Marktes
Alexander Loechel
 
Web Accessibility for Web Developers
Web Accessibility for Web DevelopersWeb Accessibility for Web Developers
Web Accessibility for Web Developers
Alexander Loechel
 
World Plone Day 2017 - Plone 5.1
World Plone Day 2017 - Plone 5.1World Plone Day 2017 - Plone 5.1
World Plone Day 2017 - Plone 5.1
Alexander Loechel
 
Lightning Talk: Security matters @ploneconf 2014
Lightning Talk: Security matters @ploneconf 2014Lightning Talk: Security matters @ploneconf 2014
Lightning Talk: Security matters @ploneconf 2014
Alexander Loechel
 

More from Alexander Loechel (12)

Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...
Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...
Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...
 
The Plone is dead, long live the Plone!
The Plone is dead, long live the Plone!The Plone is dead, long live the Plone!
The Plone is dead, long live the Plone!
 
We are the Plone Collective. Resistance is futile. Assimilation is inevitable.
We are the Plone Collective. Resistance is futile. Assimilation is inevitable.We are the Plone Collective. Resistance is futile. Assimilation is inevitable.
We are the Plone Collective. Resistance is futile. Assimilation is inevitable.
 
Plone.org Improvements - Plone Addon Listing
Plone.org Improvements - Plone Addon ListingPlone.org Improvements - Plone Addon Listing
Plone.org Improvements - Plone Addon Listing
 
Plone, quo vadis?
Plone, quo vadis?Plone, quo vadis?
Plone, quo vadis?
 
Sphinx options to make training documentation easier to understand
Sphinx options to make training documentation easier to understandSphinx options to make training documentation easier to understand
Sphinx options to make training documentation easier to understand
 
Web Content-Management-Systeme the Past - the Present - the Future
Web Content-Management-Systeme the Past - the Present - the FutureWeb Content-Management-Systeme the Past - the Present - the Future
Web Content-Management-Systeme the Past - the Present - the Future
 
Plone, the Python CMS & Web Framework for Advanced Topics and Non-Developers
Plone, the Python CMS & Web Framework for Advanced Topics and Non-DevelopersPlone, the Python CMS & Web Framework for Advanced Topics and Non-Developers
Plone, the Python CMS & Web Framework for Advanced Topics and Non-Developers
 
Plone im Kontext des WCMS Marktes
Plone im Kontext des WCMS MarktesPlone im Kontext des WCMS Marktes
Plone im Kontext des WCMS Marktes
 
Web Accessibility for Web Developers
Web Accessibility for Web DevelopersWeb Accessibility for Web Developers
Web Accessibility for Web Developers
 
World Plone Day 2017 - Plone 5.1
World Plone Day 2017 - Plone 5.1World Plone Day 2017 - Plone 5.1
World Plone Day 2017 - Plone 5.1
 
Lightning Talk: Security matters @ploneconf 2014
Lightning Talk: Security matters @ploneconf 2014Lightning Talk: Security matters @ploneconf 2014
Lightning Talk: Security matters @ploneconf 2014
 

Recently uploaded

Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 

Recently uploaded (20)

Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 

Doing the Impossible

  • 1. Doing the Impossible Porting RestrictedPython to Python 3 The way to Python 3 for Plone? Alexander Loechel PloneConf 2017 - Barcelona 1
  • 2. –Johnny Appleseed “Type a quote here.” 2 End of Life for Python 2 by 2020 PyCon (April 12th 2020)
  • 3. PloneConf 2014 Bristol - Plone Roadmap Discussion “Plone on Python 3 
 is impossible, there are too 
 many blockers in Zope. Especially RestrictedPython & AccessControl” 3
  • 4. Clarke's First Law – Arthur C. Clarke “When a distinguished but elderly scientist states that something is possible, he is almost certainly right. 
 When he states that something is impossible, he is very probably wrong.” 4
  • 5. – 2015 - Start looking into RestrictedPython “Why should RestrictedPython be the major blocker for 
 Plone on Python 3?” 5
  • 6. Hanno Schlichting - Zope Release Manager „Every piece of Zope that was not adopted by Plone is literally dead.“ 6
  • 7. „Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.“ 7 - Brian Kernighan Almost no documentation low test coverage
  • 8. Python community - around 2000 „Where Zope leads, Python follows“ 8 Zope specific leftovers in the Python 2 Standard Library Deprecated Python Standard Library Modules: • compiler Package (no described upgrade path, almost no documentation)
  • 9. Clarke's Second Law – Arthur C. Clarke “The only way of discovering the limits of the possible is to venture a little way past them into the impossible.” 9
  • 10. Clarke's Third Law – Arthur C. Clarke “Any sufficiently 
 advanced technology 
 is indistinguishable 
 from magic.” 10
  • 11. • TTW (Through-The-Web) • PythonScripts • DocumentTemplate • Workflows • Zope ZCatalog 11
  • 13. A Workshop on Python at NIST
 SPAM 1 - First PyCon (1994) - Topics I've assembled a strawman list of topics for discussion. New topics
 and comments on the topics listed are certainly welcome. A.Requirements for a "Safe" Python interpreter B. A standard GUI module interface definition for Python C.The requirements for persistent objects in Python D.A Python engineering graphs package E. The standard Python WWW interface F. Embedding Python in a WWW client G.Technical information management using Python H.Support for dynamic loading of foreign language modules in Python I. Replacing make, rcs, and cvs with Python J. An Electronic Data Interchange library for Python K. Discussing the formation of a Python Consortium 13
  • 14. Rich Hickey “Most of the biggest problem 
 in software are problems of misconception.” 14
  • 15. No Sandbox Sandboxes most often don’t work 15
  • 16. Limited, „Safe“ Subset of the Python Programming Language / Grammar • No more Turing Complete • Common Technique (Ada RavenScar Profile) 16
  • 17. The Way to RestrictedPython 4.0 and Python 3 17
  • 18. - John Johnson “First, solve the problem. Then, write the code.” 18
  • 19. • Python 2 Standard Library Module compiler and its Class ast • Not fully documented • No upgrade path for Python 3 described • manual Byte-Code generator • Interpreter specifics —> Only CPython 2 compatible 19
  • 20. If it is not documented it is not usable
 if it is not tested it did not work
 if it is not checked into version control it did not exists
 if it is not repeatable it is not science • Compiler knowledge was necessary to port RestrictedPython • I did have a degree in Informatics (Computer Science) and 
 learned how to build and manipulate compilers, so give it a try. 20
  • 21. Plone Open Garden 2015 Start looking into RestrictedPython 21
  • 22. Kent Beck “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” 22 Reading & 
 understanding the Code
  • 23. Louis Sreygley “Without requirements or design, programming is the art of adding bugs to an empty text file.” 23 Documentation First + Test Driven Development
  • 24. • compiler.ast => ast.AST • builtin compile() function since Python 2.6 accepts ast.AST as input and compiles to Python Byte-Code —> Interpreter independence • compile(source, filename, mode [, flags=ast.PyCF_ONLY_AST [, dont_inherit]]) 
 or ast.parse() return ast.AST With Python 2.6+ / 3.4+ RestrictedPython could be easier to implement 24
  • 25. Got Access to Zope Foundation Repositories via Tres Seaver at Plone Symposium Tokyo 2015 “Access Required.” 25
  • 26. >>> import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. … PEP 20 - 19. Aug. 2004 https://www.python.org/dev/peps/pep-0020/ 26 Apply Python’s PEP8 and Plone’s Coding Conventions —> Make the Code more readable
  • 27. – Richard Feynman “The first principle is that you must not fool yourself — and you are the easiest person to fool.” 27 Writing Tests & raising test coverage —> Functional Test of all Python Syntax cases
  • 28. tox & . • tox: local tests of multiple python versions • pytest: modern Python testing framework, that allows: • parameterisation (inputs and functions) • skip_if • assert Talk: Modern Python Testing 28
  • 29. Test example (pytest) c_exec = (c_exec‘, [ 
 RestrictedPython.compile.compile_restricted_exec,
 RestrictedPython.RCompile.compile_restricted_exec,
 ]) @pytest.mark.parametrize(*c_exec) def test_(c_exec): result = c_exec('a = max([1, 2, 3])')
 assert result.errors == () loc = {} exec(result.code, {}, loc) assert loc['a'] == 3 assert result.used_names == {'max': True} 29
  • 30. Alpine City Sprint 2016 / 2017 Join in of Gocept & other Zope Core Developers 30
  • 31. Ian Hickson „Things that are impossible
 just take longer.“ 31
  • 32. May 2017 Release of RestrictedPython 4.0a1 https://pypi.python.org/pypi/RestrictedPython —> 4.0.b2 Welcome to the Python 3 Wonderland32
  • 33. Philip J. Eby - Python Core Developer - Author PEP 333/3333 - WSGI „Those who do not study Zope, are condemned to reinvent it.“ 33
  • 34. Bjarne Stroustrup “If you think it’s simple, 
 then you have 
 misunderstood the problem.” 34
  • 35. My Wish Make RestrictedPython more known enable other Projects and Frameworks to use 
 a „Safe“ Python Interpreter through the Web
  • 36. John Gall - Systemantics: How Systems Really Work and How They Fail A complex system that works is invariably
 found to have evolved from a simple system
 that worked. A complex system designed from scratch never works and cannot be patched up to make it work. 
 You have to start over with a working simple system. 36
  • 37. Lessons Learned while Porting RestrictedPython • Don’t take »„impossible“ to port / fix« statements serious • Adopt modern tools and frameworks that helps: • tox & pytest —> Update Best Practices for Plone development 37
  • 38. Some further Talk recommendations • Zope on Python 3
 Hanno Schlichting - Friday 14:30-15:15 - Auditori • Modern Python Testing
 Alexander Loechel - Thursday 14:30-15:15 - Sala d'actes • subtemplates in bobtemplates.plone or on the way to plonecli 
 Maik Derstappen - Friday 15:25-15:55 - Sala d'actes 38
  • 39. Clarke's Law of Revolutionary Ideas – Arthur C. Clarke Every revolutionary idea 
 — in science, politics, art, or whatever — 
 seems to evoke three stages of reaction. 
 They may be summed up by the phrases: 1. "It's completely impossible — don't waste my time" 2. "It's possible, but it's not worth doing" 3. "I said it was a good idea all along" 39