the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful...

31
EuroPython 2015 the Python-only web framework Iwan Vosloo

Transcript of the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful...

Page 1: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

the Python-only web frameworkIwan Vosloo

Page 2: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

15 Python

Financial industry / in-house development

10

About

zope

8026 600 loc(40% tests)

Page 3: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

● Background● What it is● How it works● Why you should care● Strategy● Status● Questions

the Python-only web framework

Page 4: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Background

Web frameworks

def func(code code co) code code code code code

code

GET /some/urlmap url to some code

1

HTMLTemplate

<html> <body> </body></html>

2read from a database

3merge data with template

4respond final HTML

Page 5: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Background

Web frameworks

def func(code code co)

re-use templates css frameworks js libraries

Page 6: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Background

Technology focus

HTTP (routing)

HTML (template language)

Javascript (js libraries)

CSS (other frontend libraries)

Page 7: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

What it is

Goal focus

HTTP (routing)

HTML (template language)

Javascript (js libraries)

CSS (other frontend libraries)

Save

Name:

Email:

Add Address

Address BookJohn: [email protected]

View: / View: /add

Button

how

Page 8: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Widget

What it is

Pages are widgets

Save

Name:

Email:

Widget

Widget

Page 9: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

What it is

Composing widgets

panel1 = Div(view) panel1.add_child( P(view, text='a paragraph with text') )

Div

a paragraph with text P

Page 10: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

What it is

Widgets are not HTML

Page 11: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

What it is

Widgets are not HTML

sliding_panel = SlidingPanel(view)

panel1 = sliding_panel.add_panel(Div(view)) panel1.add_child(P(view, text='a paragraph with text'))

panel2 = sliding_panel.add_panel(Div(view)) panel2.add_child(P(view, text='a different paragraph'))

Page 12: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

What it is

Widgets are not HTML

Page 13: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

How it works

Behind the SlidingPanel

GET /some/url?index=2

HTML (showing second panel)

JS

Page 14: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

How it works

Behind the SlidingPanel

HTTP (routing)HTML (template language)

Javascript (js libraries)CSS (other frontend libraries)

Server-side logic

Extra URLs & Query string arguments

SlidingPanel

how

Page 15: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

How it works

Widget lifetime

Add Address

Address BookJohn: [email protected]

AddressBookPanel

Page 16: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

How it works

Widget lifetime

class AddressBookPanel(Div): def __init__(self, view): super(AddressBookPanel, self).__init__(view)

self.add_child(H(view, 1, text='Address Book')) for address in Session.query(Address).all(): self.add_child(AddressBox(view, address))

Page 17: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

How it works

Defining a UserInterface

Save

Name:

Email:

Add Address

Address BookJohn: [email protected]

View: / View: /add

Page 18: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

How it works

Defining a UserInterfaceclass AddressBookUI(UserInterface):

def assemble(self):

addresses = self.define_view('/', title='Addresses') addresses.set_page(HomePage.factory())

add = self.define_view('/add', title='Add an address') add.set_page(AddPage.factory())

self.define_transition(Address.events.save, add, addresses)

Page 19: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Why you should care

Page 20: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Why you should care

Knowledge & focus

Widget

TextInput

ValidationConstraint

Event

Action

Field Layout

Button

forget technological details

CheckboxInput

Menu

TabbedPanel

Page 21: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Why you should care

Re-useWidget

TextInputValidationConstraint

Event

Action FieldLayout

Button

i18naccess control accessabilitygraceful degradation

forget technological details

Menu

double submitconcurrency security issues quirks

Page 22: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Why you should care

Complicated requirements

Page 23: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Strategy

“No-html” frameworks

main stream no-html

Page 24: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Strategy

Maintain web semantics

● Tabbed browsing● Bookmarks● Back button● ...

Page 25: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Strategy

Support web ideals

● JavaScript optional● Device independence● Accessibility● ...

Page 26: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Strategy

Web-grown API

JS JS

JS

Page 27: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Strategy

Aim: higher level issues

Save

Name:

Email:

Add Address

Address BookJohn: [email protected]

Page 28: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Strategy

Leverage existing wisdom

Page 29: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Status

Our journey

idealisticimpossible

foundationriskconcrete

more flexibilitybells & whistlesinterest & community

Page 30: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Dream

You’re invited

1. Look at examples2. Join mailing list(s)3. Install4. Follow tutorial5. Help

spread the word

infra-structure

evolvecore

grow up

Page 31: the Python-only web framework · 2015. 12. 23. · access control i18n accessability graceful degradation forget technological details Menu concurrency double submit security issues

EuroPython 2015

Thanks

On groups.google.com:● reahl-announce● reahl-discuss

www.reahl.org@reahl

[email protected]