Lightning talks day 3 - Djangocon.eu

Tags: django, djangocon

html5lib

Browsers are terribly forgiving. Python’s parsers don’t deal with everything, even valid html5 docs. html5lib was a problem. Google code and so and not python 3 compatible.

The new html5lib supports python 3. Github, readthedocs, works fine!

See https://pypi.python.org/pypi/html5lib

Real time web - Aymeric Augustin

He looked at web sockets in django. He played with tulip, Guido’s library for async python. He had 1000 processes calculating a ‘game of life’ screen and django connected with them just fine and pushed the result to the browser.

PyWaw

PyWaw is a python community in Warsaw. They have now had 24 meetings with about 55 attendees. At the last meeting they even had 100 people attending.

They are not alone in Poland, there are other user groups.

So… go back to your cities and start user groups!

Scrapy

Screen scraping is when you need to get structured information from the web, quickly and with no hassle.

Scrapy takes the hassle out of screen scaping. It takes away the pain of parsing horrible html.

It has perfect documentation and a helpful community.

You can even scrape from amazon, even including logging in.

What can you do? Convert SVG to VML. Stock checker for a market place. Testing your own website.

Motivating users - Aaron Bassett

How to motivate kids aged 7-17 to learn online. Don’t give rewards. If you give rewards, that means that the task must be really shit. Rewards don’t scale either. After initial success, do you increase the reward?

Everyone is addicted to dopamine, the stuff you get in your head when you like something. Don’t give a reward always, because that turns play (which kids like) into work.

They did some tests: random rewards do seem to work. So that’s something you can look at.

Better model inheritance - Craig de Stigter

There are three kinds of model inheritance now in Django:

  • Proxy models.

  • Abstract models.

  • Multi-table.

None fit exactly with his usecase.

What he made was django-typed-models. A bit like proxy models, but it does store the type of the object in a type field, so you can figure out what you actually are.

They even use python magery for re-casting objects as a different type: self.__class__ = NewClass :-)

Django-fluent CMS - Diederik van der Boor

It is a CMS he build for his own CMS. Many CMSs are, in the end, monolythic.

He made a CMS that consists of separate parts. If you just want a tree of pages, use django-fluent-pages. If you just want an editable main part of a page, use another app. Etcetera.

See https://pypi.python.org/pypi/django-fluent-pages/, https://pypi.python.org/pypi/django-fluent-contents/

And you can also use django-fluent-dashboard, a more beautiful admin skin.

Update: he’s got a website now: http://django-fluent.org/

Adventurer in the land of production environment - Maciej Pasternacki

Is your production enviroment up? Use a monitor like http://pingdom.com.

Django should not run as root. Run it with gunicorn and nginx, for instance.

Get immune to surprise upgrades: pip freeze.

Amulet of life saving: re-spawn when death with supervisord.

Stun immunity: a crontab with @reboot, for instance.

Acquire skill: chef, puppet.

The final battle: the slashdot effect. Gear up: autoscaling, self-healing.

New core committer

Marc Tamlyn is the new core committer!

Invisible and intentional management - Darin Swanson

Your project is not code, your project is your people. Make them happy. Make them do the best they can, no more, no less. Keep them leveling up.

Reward teamwork. It is not about the individual. Don’t have individual goals, have team roles instead. Talk about “we” and “us”. Lead by example. Help the team. Help everyone do better.

If you’re a manager, try to be invisible. You’re behind the scenes. Multiplying your impact behind the scenes. Don’t take credit, the credit is for the team.

Move people to autonomy. Stay away from command and control. Set degrees of freedom and let people grow.

There’s an implicit contract between you and your teammember: I’ll give you freedom, you’ll share status and information with me.

Discard what doesn’t work, double down on what does. Especially regarding teamwork.

Do try to become better yourself, too. Find a mentor, read books, talk with others.

Relationships - Daniele Procida

There are 7E9 people in the world. Is your relationship really the best choice? Mathemetically not. Don’t worry. Instead, commit to what you have already chosen and make it the best relation for you.

Same with web frameworks. There are so many… Stop worrying about making the wrong choice, stick with the one you have already chosen and make it the best for you.

Another subject: he wrote https://github.com/evildmp/django-inspector to report on all sorts of pages that his uses have added to his system. Status codes and so.

Arduino.loal

He hacked his landlord’s garage door opener. They only had one and there were multiple people that needed to use it. So hack the opener, add an arduino and a webserver to control the garage door. They also added django-social-auth.

An enterprise level garage door opener!

SPDY - Emanuele Palazetti

How to deploy Django over SPDY. How to get that to work? Run django inside jython and thus inside java and SPDY push actually works.

3 simple ways to make your side load faster - Filip Wasilewski

  • Database connection pooling. Creating a connection can take quite some time. Connection pooling will come in django core 1.6.

  • Cache templates. Especially if you use something lik django-crispy-forms that uses lots of small templates. You only need to enable a template cacher in TEMPLATE_LOADERS in your settings.

  • pjax. Push state ajax. That helps a lot.

Salt stack - Chris Reeves

He used to use Puppet, but didn’t like the DSL. It was quite slow and wanted something better, stronger, faster.

They came accros Salt. Written in Python. Very fast. It is explicit, you control everything from the master, the clients don’t call home themselves.

In your configuration templates you can use jinja2 for loops and so.

See http://docs.saltstack.com/

His verdict: it is consise and clean.

Your webpages are too big

Why should you care?

  • Less developed countries.

  • Mobile users.

  • Overloaded wifi at django conferences.

What can you do?

  • gzip compression on the server.

  • django-htmlmin for html minification. It is still young and quite buggy at the moment.

  • css/js minification. Look at django-pipeline.

  • Do you need the full jquery? jquip has 90% of the functionality and 10% of the size. If you need the full version, use a CDN.

  • Bootstrap css: don’t hit “download” go to “customize” and make yourself a smaller version.

  • https://github.com/samastur/image-diet to optimize your images. Works out of the box with easy-thumbnails.

Being a community member - Mark Steadman

He sucks at people stuff. Small groups are OK, but bigger groups are a problem. So that’s hard when trying to integrate in a community, also the django community.

He works now on bambu-tools, a huge collection of small useful tools and components. But it needs work and fixes to make it useful for everyone.

Which is, see the first paragraph, hard for him. He’ll be at the sprints and he’ll do his best!

Django and vagrant and PyCharm

Three kinds of magic:

  • Django is beautiful. There’s magic inside, but it is beautiful magic.

  • Vagrant is non-understandable magic.

  • PyCharm was already magic in 2010 and it is even better now.

He now has something even better than magic. He has a miracle. He showed vagrant workin inside PyCharm. Looks quite nice. The debugger even works when the code runs inside the virtual machine.

Jukebox - loci

What to do when different people have different music styles, for instance at a party? Time for democracy. A website running locally on your laptop allows you to log in and vote for numbers. The highest-voted songs will be played first :-)

See https://github.com/lociii/jukebox

Classy class based views

Very handy when working with Django’s class based views: http://ccbv.co.uk

(Note: I already used a link here in my summary of Russell’s class based views talk. See http://ccbv.co.uk/projects/Django/1.5/django.views.generic.edit/UpdateView/ )

Ideas don’t solve problems - Lukasc Balcerzak

His first computer came with logo, you could move the cursor with it to draw lines. Infinite possibilities, so no goal.

There are a lot of open source projects. Does it reinvent the wheel? Does it solve a relative simple problem? Those are two ways to rate projects on.

Example one:

  • Just try reading a URL with Python. Which built-in library to use? Hard.

  • The “requests” library is a small library that solves one relatively simple problem.

Example two:

  • Django-guardian extends Django’s auth and has shortcuts for basic stuff. Much simpler.

  • Django’s auth itself is quite elaborate and hard.

Testing class based views - Benoît Chesneau

You can use django.test.client, but that is an integration test. All the middleware and so is used.

For unittests, you can use a request factory. You still test the system, the callable.

We can also do focused unittesting. We can mimic as_view():

view.request = request
view.args = args
views.kwargs = kwargs

With this, you can test your code much more focused. And you gain speed!

Further reading: http://tech.novapost.fr/django-unit-test-your-views-en.html

Django client certificates - Deni Bertovic

Why would you use client SSL certificates? Isn’t user/passwd enough?

The advantage: nginx takes care of authentication.

See https://github.com/denibertovic/django-client-certificates

Arduino - Swift

Normally you have to code in C. But now you can also do it in Python.

See https://github.com/theycallmeswift/BreakfastSerial

He demo’ed it. Very nice! Looks useful and usable and simple. Perfect.

Next conference - Remco Wendt

This is now the fifth year. We have a tradition now! High quality conferences organized for programmers by programmers. Not for profit. Great! And now the fun factor is there, too.

The fun will stay! Next year it’ll be France, on the beach, in the south! (They don’t know the exact city yet).

 
vanrees.org logo

Reinout van Rees

My name is Reinout van Rees and I program in Python, I live in the Netherlands, I cycle recumbent bikes and I have a model railway.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):