Let's revisit our first Albatross application with the simple.py sample program in the samples/templates/simple5 directory.
#!/usr/bin/python
from albatross import SimpleContext
ctx = SimpleContext('.')
templ = ctx.load_template('simple.html')
templ.to_html(ctx)
print 'Content-Type: text/html'
print
ctx.flush_content()
Now consider the template file simple.html.
<html>
<head>
<title>The CGI environment</title>
</head>
<body>
<table>
<al-exec expr="
import os
keys = os.environ.keys()
keys.sort()
">
<al-for iter="name" expr="keys">
<tr>
<td><al-value expr="name.value()"></td>
<td><al-value expr="os.environ[name.value()]"></td>
<tr>
</al-for>
</table>
</body>
</html>
You can see the program output by pointing your browser at http://www.object-craft.com.au/cgi-bin/alsamp/simple5/simple.py.
You will notice that we have completely removed any application logic from the Python program. This is a cute trick for small example programs, but it is definitely a bad idea for any real application.