= Introduction = An Albatross application can be deployed in a web server as a CGI (albatross.cgiapp), FastCGI (albatross.fcgiapp) or mod_python (albatross.apacheapp) application. It can also be deployed as a standalone HTTP server (albatross.httpdapp). To demonstrate each of these deployment options we're going to use a simple, single page application and a series of deployment scripts. If you want to rebuild this entire example then you can copy all of the following files to a single directory that is accessible to Apache. (Don't forget to make the CGI scripts executable.) = The Application = First, here's the application module, app.py: {{{ #!python from albatross import SimpleApp class Home: name = 'home' def page_display(self, ctx): ctx.run_template('home.html') class App(SimpleApp): def __init__(self, base_url, base_dir): SimpleApp.__init__( self, base_url=base_url, template_path=base_dir, start_page=Home.name, secret='-=secret=-' ) self.register_page(Home.name, Home()) }}} And here's the home.html template: {{{

Boo!

}}} One thing to note is that app.py contains no deployment code. It's possible to put the deployment code into the application's main module but we're going to use separate "connector" scripts for this demonstration so that the application code needs no changes. = Deployment Scripts = == Web Server == The deployment scripts, or "connector" scripts as I like to call them, are extremely simple. Their only purpose is to create an application instance and connect it to the web server. Hopefully the scripts are obvious so I will not go into much (if any) detail. As mentioned above, I used Apache to test these. Here's a simple .htaccess file that may help: {{{ Options +ExecCGI AddHandler cgi-script cgi AddHandler fastcgi-script fcgi AddHandler python-program py PythonHandler connector }}} === CGI === CGIs are run from the directory they are in so the application's base_dir can be '.'. connector.cgi: {{{ #!/usr/bin/python from albatross import cgiapp import app theApp = app.App('connector.cgi', '.') theApp.run(cgiapp.Request()) }}} === FastCGI === FastCGIs, like CGIs, are run from the directory of the script. connector.fcgi: {{{ #!/usr/bin/python from albatross import fcgiapp import app theApp = app.App('connector.fcgi', '.') while fcgiapp.running(): theApp.run(fcgiapp.Request()) }}} === mod_python === mod_python programs run inside Apache. mod_python adds the script's directory to the sys.path but the current working directory could be anywhere so this time we need to be explicit about where the application is installed so that the templates can be found. connector.py: {{{ #!python from albatross import apacheapp import app base_dir = '/home/matt/public_html/albatross/deploy' theApp = app.App('connector.py', base_dir) def handler(req): return theApp.run(apacheapp.Request(req)) }}} == Standalone Server == The albatross.httpdapp module contains a simple, standalone HTTP server (based on Python's BaseHTTPServer) and a helper script, al-httpd. standalone.py: {{{ #!/usr/bin/python from albatross import httpdapp import app theApp = app.App('/', '.') }}} To run it use "al-httpd standalone.theApp 8001".