Python Users Netherlands meeting 15 January 2014
Summary of the meeting of the Dutch Python Users group on 15 January 2014.
We were welcome at the offices of Schuberg Philis in Schiphol-rijk for food, drink, presentations, lightning talks and meeting fellow-Pythonistas. Thanks for organizing!
Schuberg Philis is doing managed hosting, with high uptime.
Pini Reznik - Ansible, Docker and Django
Pini Reznik works for Ugly Duckling.
In 1995 you had thick clients and thick servers. Well-defined stack of O/S, runtime, middleware. A monolithic physical structure.
In 2014 you often have a thin app on mobile, tablet. Various web front-ends. You have multiple environments, for example several (parts of) applications and servers running on various versions of Python and different operating systems.
Compare this with lots of different cargo that may need to be moved with trucks, trains, planes, ships, or all of them at some point. Some seventy years ago they switched to containers for shipping goods. You put things inside containers in your factory. A crane only supports one container size: it is simplified. Much easier than fitting a few pianos and barrels of oil without a container.
Common challenges in the pipeline:
- on development: set up your environment, especially when you first start for a company or a new project
- testing: a clean environment, with good tests
- acceptance: is it really similar/equal to production?
So: put your software in containers.
What is Docker? http://docker.io says: Docker is an open-source project to easily create lightweight, portable, self-sufficient containers from any application
We have a java project where every test is run in a separate docker container. This is very quick.
Docker is not a VM (virtual machine). Docker runs directly on the host operating system. A VM has much higher overhead.
Orchestration: defining and deploying multiple environments. Ansible is an orchestration engine. Key concepts:
- agentless: you only need your certificate or password and you can run on any machine. For most stuff you usually need Python on that machine though.
- language agnostic: you just need to be able to execute code; the code itself does not need to be Python. It can be a shell script, C, anything that is supported by the target machine.
- inventory: smart way to manage all the hosts. Inventory is in /etc/ansible/hosts: here you define that servers A and B are webservers, and servers C, D and E are database servers.
- playbooks: scripts that define hosts, vars, tasks, handlers. What to execute and where to execute it.
- modules: functionality written by somebody, for example for integration with docker.
Ad-hoc commands are for example:
ansible all -a "reboot" ansible webservers -a "reboot"
There is a UI around ansible. This is expensive, the rest is free.
Docker + Ansible = software configuration management done right. Everything we need for building our software is now finally in version control.
Demo. If you have a docker called ubuntu this just takes 122 milliseconds:
time docker run ubuntu ls
The docker module for ansible is a bit out of date. Docker is in early development.
Roderick Schaefer - Django as your Backbone
Roderick Schaefer is currently working for Schuberg Philis. See also https://wehandle.it. We do mission critical outsourcing. Say you have a bank and need a guaranteed 100 percent uptime. We can do that. We embrace devops. My devops team works on a project called Connect. We love Python and Django.
Old school web development: Django with MTV/MVC pattern. Model, template/view, controller.
New school: API driven. We use: Python, Django, jQuery, TastyPie (REST framework), Backbone, Require.js, Underscore, Handlebars, Backbone-TastyPie. It just makes sense to work API driven. With APIs you can securely expose databases. The front-ends consume, process and present. Your average phone is faster than your average few-years-old server.
Introduction to TastyPie. This is a tool you hook up to Django to expose your Django models. It can also expose non ORM-related data. Include authorization. Serialization with json.
Backbone. Frontend MVC framework. Uses Underscore.js and friends. Template rendering, routing (note: try to do only routing here, do not corrupt it with other stuff), models, collections, events.
For 'patch' support and file upload to work in Backbone plus TastyPie, you need a few changes in your code. There is form generation with Backbone-Forms.js.
A tip when transitioning to api based development. Wrap your base.html javascripts in a block. Empty that block in your Backbone powered apps. Include some legacy-scripts template from the template of your backbone app, for compatibility with generic stuff like the main navigation.
Challenges are url reversal and session state awareness.
Check http://TodoMVC.com to get familiar with various MVC frameworks, including Backbone.
Look into Backbone SEO if you want to use this for sites where you do not want a single page but want to be indexable by search engines. It is possible.
And now the lightning talks.
Pawel Lewicki - Plone
Working with gw20e in Amsterdam. Plone is a Python CMS. It has everything you want. It may be scary for most of you, but it does not have to be. Try out the installer, it is quite easy. I show a recorded demo. You have content types, workflow states, you can see changes to pages and revert them.
It is Python. Enterprise ready, scales well. Fully functional application. Lots of add-ons if you want those. Very simple from a user perspective, being able to edit in the same environment as visitors see. There is a user manual as a book.
Bahadir Cambel - PythonHackers.com
I use lots of languages, but I like Python. But where to get information? irc, github, bitbucket, svn, python.org, blogs. Come to the python hackers site.
Learn and share with REPL (Read - Evaluate - Print - Loop). Discover, connect, contribute and be awesome.
Find hackers like you. Discover and discuss open source projects. Write, talk, share code. Build applications together. Read and write articles.
A single platform only for Python, with python hackers like you. A bit twitterish, with messages and following, channels, timeline.
What we use technically: Flask plus plugins, memcache, redis, postgres, cassandra, autobahn, fabric, coffeescript. Future: Apache Kafka, some clojure.
Programming is a personal expression.
Douwe van der Meij - Concepts in Django
Working at gw20e. A project may have a crm and a webshop package, with some interconnection. You may want to open source the webshop, but how can you make it work without the crm?
General concept:
- Producers contain data.
- Consumers need producers.
For this example we have the concept of a Customer. The crm app produces a Customer. The webshop app consumes a Customer. Define a CustomerConcept class. Define a foreign key from webshop to the CustomerConcept.
I created a concepts Django app. This makes apps reusable without dependencies. The only dependency is a concept. You may choose your own concept producer, different for various clients.
Related work: Zope Component Architecture.
Ilja Heitlager - MicroPython
I am a Kickstarter fan. Information Officer at Schuberg Philis.
Damien George came up with the MicroPython project on Kickstarter.
PyMite was first, Python on a microcontroller.
MicroPython has a dedicated board. Python 3.3. Compiler/code generator on the board. Much faster. Library support, wifi board.
Participate on http://www.micropython.org
Expected: April 2014.