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

Post on 03-Oct-2020

8 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

EuroPython 2015

the Python-only web frameworkIwan Vosloo

EuroPython 2015

15 Python

Financial industry / in-house development

10

About

zope

8026 600 loc(40% tests)

EuroPython 2015

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

the Python-only web framework

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

EuroPython 2015

Background

Web frameworks

def func(code code co)

re-use templates css frameworks js libraries

EuroPython 2015

Background

Technology focus

HTTP (routing)

HTML (template language)

Javascript (js libraries)

CSS (other frontend libraries)

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: john@example.org

View: / View: /add

Button

how

EuroPython 2015

Widget

What it is

Pages are widgets

Save

Name:

Email:

Widget

Widget

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

EuroPython 2015

What it is

Widgets are not HTML

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'))

EuroPython 2015

What it is

Widgets are not HTML

EuroPython 2015

How it works

Behind the SlidingPanel

GET /some/url?index=2

HTML (showing second panel)

JS

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

EuroPython 2015

How it works

Widget lifetime

Add Address

Address BookJohn: john@example.org

AddressBookPanel

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))

EuroPython 2015

How it works

Defining a UserInterface

Save

Name:

Email:

Add Address

Address BookJohn: john@example.org

View: / View: /add

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)

EuroPython 2015

Why you should care

EuroPython 2015

Why you should care

Knowledge & focus

Widget

TextInput

ValidationConstraint

Event

Action

Field Layout

Button

forget technological details

CheckboxInput

Menu

TabbedPanel

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

EuroPython 2015

Why you should care

Complicated requirements

EuroPython 2015

Strategy

“No-html” frameworks

main stream no-html

EuroPython 2015

Strategy

Maintain web semantics

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

EuroPython 2015

Strategy

Support web ideals

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

EuroPython 2015

Strategy

Web-grown API

JS JS

JS

EuroPython 2015

Strategy

Aim: higher level issues

Save

Name:

Email:

Add Address

Address BookJohn: john@example.org

EuroPython 2015

Strategy

Leverage existing wisdom

EuroPython 2015

Status

Our journey

idealisticimpossible

foundationriskconcrete

more flexibilitybells & whistlesinterest & community

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

EuroPython 2015

Thanks

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

www.reahl.org@reahl

iwan@reahl.org

top related