Ian Bicking: the old part of his blog

Paste App Installation

I just made a first run at some tools in Paste Script for installing web applications.

The idea is a two-phase installation; first you install the package distribution and ask it to write out a sample configuration. Then you edit the configuration. Then you ask the application to set itself up (maybe setting up databases, making directories, etc).

This is not unlike a fancier-seeming system where there's a web interface or GUI or whatnot; except all that interaction is encapsulated in editing a text configuration file. I think this is a good technique because (a) it much much easier to implement, (b) it is consistent with later maintenance, (c) it uses a powerful native UI that many people are comfortable with (the text editor), and (d) it requires very little work for an application to support.

So, in the trunk you can do:

$ paster prepare-app \
  -f http://pythonpaste.org/package_index.html \
  PasteHelloWorld helloworld.ini
$ edit helloworld.ini
$ paster setup-app helloworld.ini

You can also combine this all into:

$ paster prepare-app \
  --edit --setup \
  -f http://pythonpaste.org/package_index.html \
  PasteHelloWorld helloworld.ini

Which will immediately open the configuration file in your editor, and when you are done editing it will set up the application. (And prepare-app also installs the application with easy_install, so it really can be just one step).

This is a pretty early prototype, really, so I'm still very interested in feedback on even the most minor details. Like, what should these commands be called?

Also, people lay out their systems differently. I have a vague concept of a "system configuration" which will determine some basics about what goes where. But it's very vague. Ideally I'm hoping that hosting companies could setup such a configuration so that everything Just Works for users, including system hooks to be run on installation and whatnot. Now that I think about it, that probably means entirely new system-specific command-line options as well.

I've also written a simple class for setting up applications, so that you can add this to your application's setup.py:

setup(...
    entry_points="""
    [paste.app_install]
    main = paste.script.appinstall:Installer
    """)

This will look for a template configuration file in MyPackage.egg-info/paste_deploy_config.ini_tmpl (a Cheetah template, actually), and run mypackage.websetup.setup_config() on setup, and probably more things over time.

At some point I also plan to add such a generic setup class to SQLObject, so that a SQLObject-using application will be able to automatically set up its database on installation, as well as upgrade its database later (these classes should be reentrant, so you can run paster setup-app config_file.ini at any time to confirm and apply any new things to be setup).

Created 30 Dec '05