Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Agile web dev with Pyhon

Keith Yang
January 13, 2013

Agile web dev with Pyhon

A presentation for WebConf Taiwan 2013

Keith Yang

January 13, 2013
Tweet

More Decks by Keith Yang

Other Decks in Technology

Transcript

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  5. WebConf.TW 2013
    THAT
    simple, Dear.

    View full-size slide

  6. WebConf.TW 2013
    T^T
    simple, Tear.

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  9. WebConf.TW 2013
    Hold on

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  16. 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

    View full-size slide

  17. 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.

    View full-size slide

  18. 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.

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  23. 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

    View full-size slide

  24. WebConf.TW 2013
    Looking for good

    View full-size slide

  25. WebConf.TW 2013
    Looking for good

    View full-size slide

  26. WebConf.TW 2013
    Looking for good
    Coder
    Dev Ops

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  34. WebConf.TW 2013
    “Simple, Stupid Language”

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  51. 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

    View full-size slide

  52. 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

    View full-size slide

  53. 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!

    View full-size slide

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

    View full-size slide

  55. WebConf.TW 2013
    Documentation
    by Georg Brandl.

    View full-size slide

  56. WebConf.TW 2013

    View full-size slide

  57. 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

    View full-size slide

  58. 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”

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  64. 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

    View full-size slide

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

    View full-size slide

  66. 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

    View full-size slide

  67. 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.

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  73. WebConf.TW 2013
    Be agile
    but not scrumover#ow

    View full-size slide

  74. WebConf.TW 2013
    Choose good

    View full-size slide

  75. 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

    View full-size slide

  76. WebConf.TW 2013
    Q & A

    View full-size slide