Slide 1

Slide 1 text

Agile web dev with Python a presentation by Keith Yang for WebConf Taiwan 2013 @keitheis http://quest.keitheis.org/

Slide 2

Slide 2 text

WebConf.TW 2013 How to learn Python from zero to web development? A question on programmers.stackexchange.com

Slide 3

Slide 3 text

WebConf.TW 2013 How to learn Python from zero to web development? A question on programmers.stackexchange.com

Slide 4

Slide 4 text

WebConf.TW 2013 How to learn Python from zero to web development? A question on programmers.stackexchange.com Just go over 14 tutorials.

Slide 5

Slide 5 text

WebConf.TW 2013 THAT simple, Dear.

Slide 6

Slide 6 text

WebConf.TW 2013 T^T simple, Tear.

Slide 7

Slide 7 text

WebConf.TW 2013 T^T simple, Tear. (括號:哭哭)

Slide 8

Slide 8 text

WebConf.TW 2013 Any one who likes Ruby or PHP ?

Slide 9

Slide 9 text

WebConf.TW 2013 Hold on

Slide 10

Slide 10 text

WebConf.TW 2013 It’s not that easier for any_language in web_development

Slide 11

Slide 11 text

WebConf.TW 2013 Then, how can we make it better?

Slide 12

Slide 12 text

WebConf.TW 2013 Good is meant to be chosen that’s why we’re here.

Slide 13

Slide 13 text

WebConf.TW 2013 Choosing good... • Language • Framework • Library • Application • Methodology • Architecture • Team • Organization

Slide 14

Slide 14 text

WebConf.TW 2013 >>> assert True or False We’re interested: Agile Web Python

Slide 15

Slide 15 text

WebConf.TW 2013 >>> assert True or False We’re interested: Agile Web Python Taiwan

Slide 16

Slide 16 text

WebConf.TW 2013 >>> assert True and False Traceback (most recent call last): File "", line 1, in AssertionError Traceback (most recent call last): File "", line 1, in AssertionError

Slide 17

Slide 17 text

WebConf.TW 2013 >>> assert True and False Traceback (most recent call last): File "", line 1, in AssertionError Traceback (most recent call last): File "", line 1, in AssertionError raise Exception quickly.

Slide 18

Slide 18 text

WebConf.TW 2013 Exception You can choose not to raise it now, you will be !ne except it may come to visit you often, sometimes secretly.

Slide 19

Slide 19 text

WebConf.TW 2013 Keith Yang architect.py at biideal yet another di"erent e-commerce provider Taipei.py organizer PyCon Taiwan sta"

Slide 20

Slide 20 text

WebConf.TW 2013 Keith Yang architect.py at biideal yet another di"erent e-commerce provider Taipei.py organizer PyCon Taiwan sta" 2012 2013 ...

Slide 21

Slide 21 text

WebConf.TW 2013 Monthly meeting Python user group in Taipei Taipei.py

Slide 22

Slide 22 text

WebConf.TW 2013 We’re using Python And not just us. Python has been popular in parts of the startups

Slide 23

Slide 23 text

WebConf.TW 2013 We’re using Python And not just us. Python has been popular in parts of the startups Instagram, FriendFeed, ... how Facebook [like] it

Slide 24

Slide 24 text

WebConf.TW 2013 Looking for good

Slide 25

Slide 25 text

WebConf.TW 2013 Looking for good

Slide 26

Slide 26 text

WebConf.TW 2013 Looking for good Coder Dev Ops

Slide 27

Slide 27 text

WebConf.TW 2013 The best agile toolkit for Python web dev?

Slide 28

Slide 28 text

WebConf.TW 2013 Python itself. Yeah, you know the secret...

Slide 29

Slide 29 text

WebConf.TW 2013 Python itself. Yeah, you know the secret...

Slide 30

Slide 30 text

WebConf.TW 2013 “Nobody got !red for choosing Python”

Slide 31

Slide 31 text

WebConf.TW 2013 “Nobody got !red for choosing Python” not me, not yet

Slide 32

Slide 32 text

WebConf.TW 2013 Python is good by people who is using it

Slide 33

Slide 33 text

WebConf.TW 2013 Python is good by people who is using it be careful with magic project that supports injection of apps, plugins, extensions

Slide 34

Slide 34 text

WebConf.TW 2013 “Simple, Stupid Language”

Slide 35

Slide 35 text

WebConf.TW 2013 “Simple, Stupid Language” Not much surprise Not much magic No all day debug of $%@!? variables

Slide 36

Slide 36 text

WebConf.TW 2013 It practices elegance Rethink code in hands. Just do it

Slide 37

Slide 37 text

WebConf.TW 2013 It practices elegance Rethink code in hands. Just do it better.

Slide 38

Slide 38 text

WebConf.TW 2013 Web Toolkits Most popular one v.s. My opinionated one v.s. Alternatives

Slide 39

Slide 39 text

WebConf.TW 2013 Web Frameworks of Python ... lots • Django • Pyramid • Flask • Tornado • Web2py, Turbogears, bottle.py, ...

Slide 40

Slide 40 text

WebConf.TW 2013 Web Frameworks of Python ... lots • Django • Pyramid • Flask • Tornado • Web2py, Turbogears, bottle.py, ... ALL AGILE!

Slide 41

Slide 41 text

WebConf.TW 2013 Web Frameworks of Python ... lots • Django • Pyramid • Flask • Tornado • Web2py, Turbogears, bottle.py, ... ALL AGILE! Ready for RESTful

Slide 42

Slide 42 text

WebConf.TW 2013 As long as you know PEP 8 or The Hitchhiker’s Guide to Python!

Slide 43

Slide 43 text

WebConf.TW 2013 As long as you know PEP 8 or The Hitchhiker’s Guide to Python! Good style to follow

Slide 44

Slide 44 text

WebConf.TW 2013 Code Indention from the very beginning. Seems that Co"eeScript loves it.

Slide 45

Slide 45 text

WebConf.TW 2013 It’s important You can make choice between several well developed choices. Not just ONE there.

Slide 46

Slide 46 text

WebConf.TW 2013 How to pick a web framework from “Just pick a good one.” to “I’ve compared EVERYTHING.”

Slide 47

Slide 47 text

WebConf.TW 2013 How to pick a web framework Goal Scale Resources

Slide 48

Slide 48 text

WebConf.TW 2013 How to pick a web framework Goal: Blog, Wiki, EC Platform Scale: Personal, Studio, Company, Enterprise Resources: Schedule, Support

Slide 49

Slide 49 text

WebConf.TW 2013 How to pick a web framework Micro: bottle.py Mini: Flask by Armin Ronacher by Marcel Hellkamp

Slide 50

Slide 50 text

WebConf.TW 2013 How to pick a web framework Micro: bottle.py Mini: Flask Middle: Django, Pyramid, web2py by Armin Ronacher by Marcel Hellkamp

Slide 51

Slide 51 text

WebConf.TW 2013 How to pick a web framework Micro: bottle.py Mini: Flask Middle: Django, Pyramid, web2py Other: you’ll know what you want. by Armin Ronacher by Marcel Hellkamp

Slide 52

Slide 52 text

WebConf.TW 2013 What Makes Pyramid Unique Single-!le applications Decorator-based con!g URL generation Debug Toolbar Add-ons Class-based and function-based views Asset speci!cations Extensible templating Event system No any “mutable globals” Transaction management

Slide 53

Slide 53 text

WebConf.TW 2013 What Makes Pyramid Unique Single-!le applications Decorator-based con!g URL generation Debug Toolbar Add-ons Class-based and function-based views Asset speci!cations Extensible templating Event system No any “mutable globals” Transaction management Lots more!

Slide 54

Slide 54 text

WebConf.TW 2013 How to setup environment virtualenv + pip Search: “keitheis pip” for my tutorial

Slide 55

Slide 55 text

WebConf.TW 2013 Documentation by Georg Brandl.

Slide 56

Slide 56 text

WebConf.TW 2013

Slide 57

Slide 57 text

WebConf.TW 2013 Object-Relational Mapping •SQLAlchemy unless you’re using Django ORM or web2py DAL • You might also be interested in: MongoKit structured schema and validation layer

Slide 58

Slide 58 text

WebConf.TW 2013 Template •Mako or Jinja2 unless you’re using Django Template • You might also be interested in: Plim “a Python port of Ruby’s Slim template language built on top of the Mako Templates”

Slide 59

Slide 59 text

WebConf.TW 2013 Manage Web Assets “webassets - Asset management for Python” • with Django • with Flask • with Pyramid • other or no framework

Slide 60

Slide 60 text

WebConf.TW 2013 Do it later Celery asynchronous task queue/job queue based on distributed message passing

Slide 61

Slide 61 text

WebConf.TW 2013 Testing •Nosetests (Django-nose?) • You might also be interested in: pytest more powerful, detail, #exible and complex

Slide 62

Slide 62 text

WebConf.TW 2013 Coding tool •Sublime Text 2 powered by Python •PyDev more powerful, detail, #exible and complex • Lots... Emacs, Vim, ...

Slide 63

Slide 63 text

WebConf.TW 2013 Coding tool •Sublime Text 2 powered by Python •PyDev more powerful, detail, #exible and complex • Lots... Emacs, Vim, ...

Slide 64

Slide 64 text

WebConf.TW 2013 Deployment •Fabric + cuisine Server(s) administration in Python • You might also be interested in: Plumbum di"erent style... # sudo[ls["-l", "-a"]] by Christian Vest Hansen and Jeffrey E. Forcier. by Sebastien Pierre by Tomer Filiba

Slide 65

Slide 65 text

WebConf.TW 2013 Fabric + cuisine def restart_service(service_name, time_interval=1): stop_service(service_name) time.sleep(time_interval) # Avoid time attack start_service(service_name) def stop_service(service_name): return sudo( 'service {service_name} stop'.format( service_name=service_name)) def start_service(service_name): return sudo( 'service {service_name} start'.format( service_name=service_name))

Slide 66

Slide 66 text

WebConf.TW 2013 Process Management •Supervisor monitor and control a number of processes on UNIX-like operating systems. • You might also be interested in: Circus.io process & socket manager. by Agendaless by Mozilla

Slide 67

Slide 67 text

WebConf.TW 2013 Powerful Data Computing If you’re going to have numbers, you won’t hope to learn one more language for statistic and analysis.

Slide 68

Slide 68 text

WebConf.TW 2013 Python User Group in Taiwan Communities: PyHUG #  Taipei.py # 

Slide 69

Slide 69 text

WebConf.TW 2013 Python User Group in Taiwan Communities: PyHUG #  Taipei.py #  Yilan, Tainan, Kaohsiung, Kinmen, ... #

Slide 70

Slide 70 text

WebConf.TW 2013 PyCon Taiwan 2013 after PyCon.TW 2012 fantasy #  tw.pycon.org

Slide 71

Slide 71 text

WebConf.TW 2013 PyCon Taiwan 2013 after PyCon.TW 2012 fantasy #  Call for Proposals tw.pycon.org

Slide 72

Slide 72 text

WebConf.TW 2013 PyCon Taiwan 2013 after PyCon.TW 2012 fantasy #  Call for Proposals and Sponsorship tw.pycon.org

Slide 73

Slide 73 text

WebConf.TW 2013 Be agile but not scrumover#ow

Slide 74

Slide 74 text

WebConf.TW 2013 Choose good

Slide 75

Slide 75 text

WebConf.TW 2013 Some Fun Demo? % python Python 2.7.2 (default, Jun 20 2012, 16:23:33) Type "help", "copyright", "credits" or "license" for more information. >>> import this

Slide 76

Slide 76 text

WebConf.TW 2013 Q & A