Timur Izhbulatov — Independent Electronic Music

Application components under shared namespace

Tue, 24 Aug 2010 21:50:00 in Tech stuff | permalink

paste python setuptools turbogears

It is often desirbale to decompose an application into several components. Perhaps one of the most common approaches is separating a model component that is responsible for data repesenataion and interaction with the database and then use it from other components. For instance, one of the other components can provide a sofisticated web-based UI to the model while another one implements a bare command-line interface.

In this situation each component is a subproject that is distributed as a separate package, in the setuptools' sense. And view each component has its corresponding directory in the project's VCS repository which contains a everything that is typicaly necessary to build an .egg, setup.py and whatever else the developer finds approprate.

A component, or subproject, usualy includes a number of modules which are organized inside a Python package. While it is possible to name the components' packages like yourappmodel, yourappweband yourappcli, The Zen of Python says:

Namespaces are one honking great idea -- let's do more of those!

And applying to our example that means the packages should be named like yourapp.model, yourapp.web and yourapp.cli.

Here I'm going to show how I work with a project that uses setuptools' namespace packages.

As an example I will be using Posy, my current project that consists of three components: