SlideShare une entreprise Scribd logo
1  sur  39
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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 HoleNoam Kfir
 
Test Driven Development With Python
Test Driven Development With PythonTest Driven Development With Python
Test Driven Development With PythonSiddhi
 
Applying TDD to Legacy Code
Applying TDD to Legacy CodeApplying TDD to Legacy Code
Applying TDD to Legacy CodeAlexander 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 PythonAndreas Schreiber
 
TDD in Python With Pytest
TDD in Python With PytestTDD in Python With Pytest
TDD in Python With PytestEddy Reyes
 
Plone Testing Tools And Techniques
Plone Testing Tools And TechniquesPlone Testing Tools And Techniques
Plone Testing Tools And TechniquesJordan 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 MalothBhavsingh 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
 
Scryent: Plone - Hone Your Test Fu
Scryent: Plone - Hone Your Test FuScryent: Plone - Hone Your Test Fu
Scryent: Plone - Hone Your Test FuJordan Baker
 
Interpreter RPG to Java
Interpreter RPG to JavaInterpreter RPG to Java
Interpreter RPG to Javafarerobe
 
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 dummiesHarry Potter
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answersITeLearn
 
Sour Pickles
Sour PicklesSour Pickles
Sour PicklesSensePost
 

Tendances (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
 

Similaire à Doing the Impossible

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 PuneEthan's Tech
 
Python @ PiTech - March 2009
Python @ PiTech - March 2009Python @ PiTech - March 2009
Python @ PiTech - March 2009tudorprodan
 
Python intro
Python introPython intro
Python introrik0
 
PyCon2022 - Building Python Extensions
PyCon2022 - Building Python ExtensionsPyCon2022 - Building Python Extensions
PyCon2022 - Building Python ExtensionsHenry Schreiner
 
Introduction to python 3 2nd round
Introduction to python 3   2nd roundIntroduction to python 3   2nd round
Introduction to python 3 2nd roundYouhei 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.pptRehnawilson1
 
Introduction to python 3
Introduction to python 3Introduction to python 3
Introduction to python 3Youhei 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 PPTShivam Gupta
 
python-160403194316.pdf
python-160403194316.pdfpython-160403194316.pdf
python-160403194316.pdfgmadhu8
 
Plone - A History of Python Web
Plone - A History of Python WebPlone - A History of Python Web
Plone - A History of Python WebAlexander Loechel
 
Py4 inf 01-intro
Py4 inf 01-introPy4 inf 01-intro
Py4 inf 01-introIshaq Ali
 
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 LanguageEdureka!
 
Pythonic doesn't mean slow!
Pythonic doesn't mean slow!Pythonic doesn't mean slow!
Pythonic doesn't mean slow!Ronan Lamy
 

Similaire à 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
PythonPython
Python
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
 
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!
 

Plus de 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 ListingAlexander 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 understandAlexander 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 FutureAlexander 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-DevelopersAlexander Loechel
 
Plone im Kontext des WCMS Marktes
Plone im Kontext des WCMS MarktesPlone im Kontext des WCMS Marktes
Plone im Kontext des WCMS MarktesAlexander Loechel
 
Web Accessibility for Web Developers
Web Accessibility for Web DevelopersWeb Accessibility for Web Developers
Web Accessibility for Web DevelopersAlexander 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.1Alexander Loechel
 
Lightning Talk: Security matters @ploneconf 2014
Lightning Talk: Security matters @ploneconf 2014Lightning Talk: Security matters @ploneconf 2014
Lightning Talk: Security matters @ploneconf 2014Alexander Loechel
 

Plus de 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
 

Dernier

Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 

Dernier (20)

Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 

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