SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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!
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxRTS corp
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxAS Design & AST.
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...kalichargn70th171
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxSasikiranMarri
 

Kürzlich hochgeladen (20)

Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptx
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptx
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
 

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