SLIDE 1 Using Python and XMPP to build a decentralized social network
J´ erˆ
FOSDEM
Saturday 30th January 2016
SLIDE 2 Some words about the project a lot of features
about the technologies global architecture Python ! about the choice of Python some advantages Twisted Urwid Pyjamas A New Hope Things we have learned Salut ` a Vous
SLIDE 3
Some words about the project
Libervia/Salut ` a Toi is a Multipurpose, multi frontend communication tool
SLIDE 4
Some words about the project
◮ project started in 2008/2009 ◮ Social Contract
http://salut-a-toi.org/social_contract.html
◮ non profit association
SLIDE 5 Outline
Some words about the project a lot of features
about the technologies global architecture Python ! about the choice of Python some advantages Twisted Urwid Pyjamas A New Hope Things we have learned Salut ` a Vous
SLIDE 6
Some words about the project
◮ instant messaging (of course) ◮ end 2 end encryption ◮ P2P file sharing ◮ blog engine (decentralized !) ◮ lot of experimentations
SLIDE 7
SLIDE 8 Outline
Some words about the project a lot of features
about the technologies global architecture Python ! about the choice of Python some advantages Twisted Urwid Pyjamas A New Hope Things we have learned Salut ` a Vous
SLIDE 9
SLIDE 10
◮ don’t reinvent the wheel ◮ we use standards (XMPP) ◮ factorization
SLIDE 11 Outline
Some words about the project a lot of features
about the technologies global architecture Python ! about the choice of Python some advantages Twisted Urwid Pyjamas A New Hope Things we have learned Salut ` a Vous
SLIDE 12
SLIDE 13
Python !
we use Python everywhere we can
◮ Twisted (backend, web frontend) ◮ curses Urwid (console frontend) ◮ Pyjamas (web frontend) ◮ WxWidgets Kivy to be done ◮ Jinja (web frontend)
. . . and sometime we don’t
◮ Qt/C++ (Desktop frontend)
SLIDE 14 Outline
Some words about the project a lot of features
about the technologies global architecture Python ! about the choice of Python some advantages Twisted Urwid Pyjamas A New Hope Things we have learned Salut ` a Vous
SLIDE 15
about the choice of Python
◮ speed (execution)
SLIDE 16 about the choice of Python
◮ speed (execution)
◮ pypy ◮ cython ◮ C/C++ inclusion
SLIDE 17 about the choice of Python
◮ speed (execution)
◮ pypy ◮ cython ◮ C/C++ inclusion
◮ speed (development) ◮ popular (libraries) ◮ popular (similar projects) ◮ popular (tools)
SLIDE 18
tools
◮ Mercurial ◮ BuildBot ◮ D-Feet
SLIDE 19 Outline
Some words about the project a lot of features
about the technologies global architecture Python ! about the choice of Python some advantages Twisted Urwid Pyjamas A New Hope Things we have learned Salut ` a Vous
SLIDE 20
some advantages
◮ debugging (pudb & ipdb) ◮ stability (Python & Twisted) ◮ workaround/monkey patching ◮ standard library (re, argparse, dom, urlparse/urllib) ◮ Python is fun !
SLIDE 21
Twisted
◮ asynchronous ◮ huge framework ◮ well thought abstractions ◮ test driven development
SLIDE 22 Twisted
◮ Deferred
def fosdemTalkCb ( s e l f , r e s u l t ) : p r i n t u”OK! {}” . format ( r e s u l t ) def fosdemTalkEb ( s e l f , f a i l u r e ) : p r i n t u” D i s a s t e r ! {}” . format ( f a i l u r e ) d = getFosdemTalkOpinion () d . addCallbacks ( s e l f . fosdemTalkCb , fosdemTalkEb )
◮ inline callbacks
@defer . i n l i n e C a l l b a c k s def fosdemTalkPoll ( s e l f ) : try :
getFosdemTalkOpinion () except BadTalkException as f a i l u r e : p r i n t u” D i s a s t e r ! {}” . format ( f a i l u r e ) e l s e : p r i n t u”OK! {}” . format ( o p i n i o n )
SLIDE 23
Urwid
◮ D-Bus integration ◮ good widgets set ◮ customization ◮ lot of nice stuff (resizing, keys, etc) ◮ it just works !
SLIDE 24
SLIDE 25 Pyjamas
◮ Python −
→ JavaScript transpiler
◮ very active at the time ◮ a GWT port ◮ handle browsers incompatibilities ◮ main advantages for us :
◮ factorization ◮ no context switch
SLIDE 26 Pyjamas
◮ it’s nearly Python, but it’s not Python ◮ heavy and ugly pages (code) ◮ difficult to debug ◮ no luck to move to Python 3 ◮ project hijacked ◮ and now dead
SLIDE 27 Outline
Some words about the project a lot of features
about the technologies global architecture Python ! about the choice of Python some advantages Twisted Urwid Pyjamas A New Hope Things we have learned Salut ` a Vous
SLIDE 28
A New Hope
Brython
SLIDE 29
A New Hope
Brython
◮ not a compiler, an interpreter ◮ Python 3 ◮ Python test suite ◮ active ◮ debugger ◮ stay close to HTML
SLIDE 30
Things we have learned
◮ stay focused ◮ new technologies can wait ◮ look for the community ◮ and the stability
SLIDE 31 Outline
Some words about the project a lot of features
about the technologies global architecture Python ! about the choice of Python some advantages Twisted Urwid Pyjamas A New Hope Things we have learned Salut ` a Vous
SLIDE 32 Thanks for your attention
◮ http://salut-a-toi.org (official website) ◮ https://www.libervia.org (d´
emo)
◮ goffi@goffi.org (courriel) ◮ goffi@jabber.fr (jid)