the Python-only web framework Iwan Vosloo EuroPython 2015
About 10 z o 80 p 26 600 loc e (40% tests) 15 Python Financial industry / in-house development EuroPython 2015
the Python-only web framework ● Background ● What it is ● How it works ● Why you should care ● Strategy ● Status ● Questions EuroPython 2015
Background Web frameworks 2 1 read from map url a GET /some/url to some database def func(code code co) code code code code code code code <html> <body> </body> 3 </html> HTML 4 Template merge respond data with final template HTML EuroPython 2015
Background Web frameworks re-use templates css frameworks js libraries def func (code code co) EuroPython 2015
Background Technology focus Javascript (js libraries) CSS (other frontend libraries) HTML (template language) HTTP (routing) EuroPython 2015
What it is Goal focus View: / View: /add Address Book Name: John: john@example.org Email: Add Address Button Save how Javascript (js libraries) CSS (other frontend libraries) HTML (template language) HTTP (routing) EuroPython 2015
What it is Pages are widgets Name: Widget Email: Widget Widget Save EuroPython 2015
What it is Composing widgets panel1 = Div (view) panel1. add_child ( P (view, text='a paragraph with text') ) Div P a paragraph with text 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 SlidingPanel how Extra URLs & Query string arguments Server-side logic Javascript (js libraries) CSS (other frontend libraries) HTML (template language) HTTP (routing) EuroPython 2015
How it works Widget lifetime AddressBookPanel Address Book John: john@example.org Add Address 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 View: / View: /add Address Book Name: John: john@example.org Email: Add Address Save EuroPython 2015
How it works Defining a UserInterface class 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 Event Widget Button Action TextInput Layout Field CheckboxInput TabbedPanel ValidationConstraint Menu forget technological details EuroPython 2015
Why you should care Re-use Widget Event Button Menu Action Field TextInput Layout ValidationConstraint concurrency double submit security issues quirks graceful access control i18n accessability degradation forget technological details 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 Address Book Name: John: john@example.org Email: Add Address Save EuroPython 2015
Strategy Leverage existing wisdom EuroPython 2015
Status Our journey more flexibility bells & whistles interest & community foundation idealistic risk impossible concrete EuroPython 2015
Dream You’re invited spread 1. Look at examples the word 2. Join mailing list(s) infra- structure 3. Install evolve 4. Follow tutorial core 5. Help grow up EuroPython 2015
Thanks www.reahl.org On groups.google.com : ● reahl-announce @reahl ● reahl-discuss iwan@reahl.org EuroPython 2015
Recommend
More recommend