====================
A Walk Through Paste
====================
:Author: Mike Orr
:Contact: mso@oz.net
:Status: alpha draft
:Version: 1
:Date: 2005-05-23
.. contents::
Introduction
------------
Paste is sticky. Taking a stroll through paste is not recommended. However,
using Paste_ to mix and match frameworks and libraries is an exciting new
frontier in Python web programming. My last article_ discussed WSGI, a
protocol designed to allow application frameworks and standalone components
called *middleware* to work together, like a Unix pipeline. Paste brings this
to a higher level, providing a meta-framework to hang these pieces onto, with a
common configuration system.
It's too early to say where all this will lead. Will Paste end the framework
wars? Can it overcome its Webware-centric origins, as it is earnestly trying
to? Will it prove sufficiently flexible that developers will overlook its
"faults" (i.e., design decisions they disagree with)? What will happen to the
dozen-some frameworks that have been ported to it? Will some gain market share
and others die? Will the emerging preferred middleware stack squash
alternatives? Maybe in a year or two we can begin to answer these questions.
Paste's creator, Ian Bicking, predicts:
With frameworks, I do hope that Paste will allow some frameworks to
wither away peacefully, as heterogeneous environments make incremental
deprecation possible. My ideal, though, is that those frameworks move
to Paste, and then natural selection does the rest; either the important
ideas from a framework are extracted, or users move away from frameworks
while still supporting legacy apps and without having to maintain
radically different environments. But there definitely won't be a
single preferred framework. As for preferences and choices, I hope
people keep discussing that and offering their opinions, but that should
happen outside of Paste. [#]_
..[#] E-mail to paste-users list dated "Mon, May 23, 2005 12:18 pm".
This article is a hands-on walk through Paste's more interesting features,
highlighting areas fruitful for future research. It's the HOWTO I
attempted to write last month but didn't, but this time focusing on a narrower
topic. Paste is undergoing rapid alpha development, so some of my examples
might not work by the time you read this. The examples are my best guess
regarding which features and syntax will be supported long term, in
consultation with Ian.
Installation
------------
Let's install Paste and run its demo programs. We'll install into /tmp/scratch
to avoid polluting our system environment with software we may not use again.
These examples assume a Linux system; Windows users may need to make
adjustments. You'll need Python 2.4 and ``svn`` (the Subversion client)
installed. The Wareweb framework will *not* work with Python 2.3 due to
@-style decorators. The rest of Paste *might* work with 2.3 but no guarantees.
Our directory structure will look like this:
- /tmp/scratch/Paste: our snapshot of Paste's Subversion repository.
- /tmp/scratch/lib: other Python packages we'll install.
- /tmp/scratch/app1: an application we'll create. (etc)
Run this in the shell::
$ python -V # Must be 2.4 or greater.
$ ls /tmp/scratch # Must not exist.
$ mkdir /tmp/scratch /tmp/scratch/lib
$ export PYTHONPATH=/tmp/scratch/lib:/tmp/scratch/Paste
$ cd /tmp/scratch
$ svn co http://svn.pythonpaste.org/Paste/trunk Paste
$ cd Paste
$ python build-pkg.py
The last command downloads a bunch of third-party Python packages needed by
Paste and installs them to /tmp/scratch/Paste/3rd-party.
..
Hyperlink targets
.. _AJAX: http://en.wikipedia.org/wiki/AJAX
.. _article: http://linuxgazette.net/113/orr.html
.. _Borg: http://en.wikipedia.org/wiki/Borg
.. _cgi2scgi.py: http://cafepy.com/quixote_extras/rex/cgi2scgi.py
.. _CGI: http://www.w3.org/CGI/
.. _Cheetah: http://cheetahtemplate.org/
.. _CherryPy: http://www.cherrypy.org/
.. _Durus: http://www.mems-exchange.org/software/durus/
.. _environment variables: http://hoohoo.ncsa.uiuc.edu/cgi/env.html
.. _Flup: http://www.saddi.com/software/flup/
.. _Nevow: http://nevow.org/
.. _Paste: http://pythonpaste.org/
.. _PEAK: http://peak.telecommunity.com/
.. _PEP 333: http://www.python.org/peps/pep-0333.html
.. _Plone: http://plone.org/
.. _PyCon 2004 article: http://www.linuxjournal.com/node/7541
.. _PyWebOff: http://pyre.third-bit.com/pyweb/index.html
.. _Quixote repository: http://cafepy.com/quixote_extras/sluggo/
.. _Quixote: http://www.mems-exchange.org/software/quixote/
.. _QWIP and SWAP: http://www.idyll.org/~t/www-tools/wsgi/
.. _SCGI: http://www.mems-exchange.org/software/scgi/
.. _Subway: http://subway.python-hosting.com/
.. _twisted: http://twistedmatrix.com/
.. _web-sig: http://python.org/sigs/web-sig/
.. _Webware: http://webwareforpython.org/
.. _WSGI Utils: http://www.owlfish.com/software/wsgiutils/
.. _wsgi_server.py: http://cafepy.com/quixote_extras/rex/wsgi_server.py
.. _ZODB: http://www.zope.org/Wikis/ZODB/FrontPage
.. _Zope: http://www.zope.org/