Using A-A-P


A-A-P is does everything what make does plus you can use python in it's recipes. Another great thing is that A-A-P uses signatures instead of timestamps to detect changed files.

The examples expect that you are using a UNIX like OS.

Using A-A-P with Webware

I did not invest too much time to write the following recipes, so I'm sure there is much room to improve/enhance them in many ways.

Assuming the following directory structure of the the application "Example":

Compiling Cheetah Templates to Servlets

To compile new and changed templates living in Templates/ and move them to Servlets/ I use the following recipe:

File main.aap in Example/Application/Servlets/:

TEMPLATES = `glob("../Templates/*.tmpl")`

SERVLETS`` `' '.join([os.path.split(tmpl)[1] for tmpl in var2list(aap_sufreplace('.tmpl', '.py', TEMPLATES))])`

:rule : ../Templates/%.tmpl
    :sys cheetah compile $source
    :move ../Templates/$target .


Since the file is called main.aap, you can compile your templates by simply changing your working directory to Servlets/ and typing "aap" at the command prompt.

First we create a list of source files (TEMPLATES) and a list of target files (SERVLETS) using python commands enclosed with backticks. Since we use the python glob function, we don't have to care about a growing number of template files.

The :rule command teaches A-A-P how to create servlets from cheetah templates. It calls cheetah as an external process, so A-A-P can use its return value to determine the success of the compilation.

Publishing the Application

File main.aap in Example/Application/Servlets/:

FILES = `glob("Lib/*.py")`

    :execute Servlets/main.aap

dist: compile
    :attr {publish = scp://user@distserver/path/to/application/%file%} $FILES

test: compile
    :attr {publish = scp://user@testserver/path/to/application/%file%} $FILES

Installing the files on the test server is simply a matter of typing "aap test publish" at the command prompt in the Application/ directory. Modified files will be compiled automatically by executing the A-A-P recipe in Servlets/.

In practice I check more dependencies (for example successful execution of unit test) before the files are copied to a server and I do other things like changing file permissions on the server after the upload.

Quite simple, isn't it?

Its very easy to define dependencies with the make like syntax and python does the rest. A powerful combination in my opinion.

What does A-A-P mean?

Bram Molenaar wrote on the a-a-p-user mailing list that "A-A-P doesn't stand for something specific".

-- AndiPoisel - 26 Feb 2003