Europython: wsgi, django, moinmoinΒΆ

Tags: europython, europython2006, plone, django

James Gardner - Developing applications with WSGI

Murphy had a field day with the projector. It worked perfectly till the presentation started. A big "clean the air filter" notice appeared and couldn't be removed. Ok, let's switch the channel. Ouch, now we're just getting some faint gray lines. Murphy's law. Kit Blake got the projector tamed again in the end :-)

His talk is much more low-level than Kevin's one, he'll basically go through the WSGI PEP .

The problem: choosing a web framework (zope, quixote, webware, twisted, etc) is tricky as you have to like the whole of the web framework as they used to come as big monolithic blocks. The WSGI interface allows the web frameworks to chop themselves up a bit and make individual parts available.

The WSGI itself is pretty simple. Your application should accept an environment (including form variables, etc) and a start_response method that you call with some optional headers when starting your response. The actual content is just that which you return.

The interface is easy to implement and it makes your application WSGI-usable with lots of other applications. You can write a separate library that does something, register it as WSGI and use it from any other WSGI-expecting app.

There's a new website at that has an overview of available middleware, utilities, documentation, etc.

Simon Willison - The django web framework

He worked for a newspaper: web development on a newspaper schedule. That newspaper Went Wild with the kids' league . They wanted a professional site for the kids' league: team descriptions, team stats, schedules, sign-up forms for parents to get email alerts, 360 degree photos of all stadiums, etc. In three days. In the end, this turned into django .

They had a great css/template designer and a couple of very capable and hard-working interns. And they were going to build it in python. And they were going to have clean URLs, a good template system (so that they could get the designer to work right away: remember, a 3-day deadline).

Views are what django developers spend the most of their time in. Methods that accept a request and send out a response. That's where the work really happens. Views are developer-oriented and thus can use lots of little utility methods.

URLs are handled with regualar expressions. If an expression matches, the request gets given to the corresponding method. The regular expression can grab certain elements out of the URL, these get passed to the method, too.

Django uses databases to store data. It can create the databases for you, which also gives you some handy methods to get your data back out of the database. One fancy thing is that most of the queries are lazy: they don't get executed till the last moment. So you can grab all data, take the first three of those and print the results: this will only query the database for the first three items.

Django templates are normal html files, sprinkled with curly braces to tell django to do things like iterating. You can have a base template that defines some extension locations that you can fill later on, for instance for putting a site header and a standard footer in there. Django's template system was designed to handle the environment they had at the newspaper.

What they did for the newspaper turned into a lot of small mini content managerment systems all bundled together. So they started a central management view to coordinate it all.

Some success stories:

Thomas Waldmann, Alexander Schremmer - MoinMoin wiki development

MoinMoin is a pretty popular wiki implementation, for instance used on parts of Ubuntu uses MoinMoin for almost all their websites, so that shows you can modify MoinMoin's looks a lot, as it doesn't look as a wiki.

Thomas showed the MoinMoin plugin types. Parsers, macros, etc. MoinMoin now has a nice plugin system, allowing you to modify individual parts of MoinMoin to your liking. Other parts are not plugins, but are meant to be extended by using interfaces: user authentication, convertors (from html to wiki markup), security policies (antispam, autoadmin, etc.).

For the actions, they have plugins. Actions are "show", "diff", "delete page", etc. Also plugins: parsers and formatters. Formatters are called for individual pieces of text, so italic text goes through the italic formatter. Adding formatter actions thereby extend the capabilities of the format.

Theme plugins customise the way that MoinMoin looks. Such a plugin consists of a bit of python code and stylesheets and icons.

MoinMoin supports Wiki xmlrpc: some standard RPC for getting/writing pages, info, page list, etc.

blog comments powered by Disqus logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

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):