Code layout

There are two code layouts:

  • the minimal layout: simple Python application.
  • the complete layout: Web application.

Minimal layout

The minimal layout is an empty application that includes all the boiler-plate code all our applications should have.

A minimal Services’ project usually contains:

  • Makefile and used to build the environment, run tests, etc.
  • RPM spec: used to build the project’s RPM.
  • a directory for the Python code.
  • README: brief intro about the project
  • defines Distutils’ options.
  • defines extra options for Distutils.

Paster Template

You can create a new application layout by using the services_base Paster template provided by MoPyTools, which will ask you a few questions:

$ paster create -t services_base MyApp
Selected and implied templates:
MoPyTools#services_base  A Mozilla Services application

egg:      MyApp
package:  myapp
project:  MyApp
Enter version (Version (like 0.1)) ['']: 0.1
Enter description (One-line description of the project) ['']: A cool app that does it
Enter author (Author name) ['']: Tarek
Enter author_email (Author email) ['']:
Enter url (URL of homepage (or Repository root)) ['']:
Creating template services_base
Generating Application...

Once the application is generated, a default layout is created:

$ find MyApp/

You can build and test that the project is ready, by going in the directory and running:

$ make build test


Every project should have a Makefile with these targets:

  • build: used to build the project in-place and all its dependencies.
  • test: used to run all tests and produce tests coverage and lint reports.
  • build_rpms: used to build all RPMs for the project.

The build target can take optional arguments to define for the project or any of its dependency that leaves in our repositories, a Mercurial tag.

For example, to build the KeyExchange project with the “rpm-0.1-10” tag, and its ServerCore dependency with the tag “rpm-0.1-15”, one may call:

$ make build SERVER_KEYEXCHANGE=rpm-0.1.10 SERVER_CORE=rpm-0.1-15

The option name is the repository named in upper case, with the dashes (“-”) replaced by underlines (“_”). So “server-core” becomes “SERVER_CORE”.

For more info on building and releasing, see Releasing an application.

The test target runs the Nose test runner, and can be used to work on the code. It’s also used by Jenkins to continuously test your project.

See 5. Build the app and all RPMS for more info on the building process.

RPM Spec file

The spec file that gets generated is used by “make build_rpm” to generate a RPM for your application. It contains all the required dependencies for a stock Services application, but will require that you add any new dependency your code needs. and


Complete layout

The complete layout contains all the things the minimal layout has, plus everything needed to make it a Web application:

  • etc/ : all default config files.
  • package/ the web application itself.
  • package/ the web controller to start adding features.
  • package/ the bootstrap file used by Gunicorn to run the app.
  • package/tests/functional/: a minimal functional test using WebTest.


All Projects repositories are located in