To start developing new code in OpenACS, we build a new package. A package is a a discrete collection of web pages, tcl code, and database tables and procedures. A package with user interface is called an application; a package which provides functions to other packages and has no direct interface, a service. A package can be installed, upgraded, and removed. It communicates with other packages through an API. This chapter walks you through the minimum steps to create a useful package, including writing documentation, setting up database tables and procedures, writing web pages, debugging, and automatic regression testing.
In this tutorial, we will make an application package for displaying a list of text notes.
You will need:
A computer with a working installation of OpenACS. If you don't have this, see Chapter 2, Installation Overview.
Example files, which are included in the standard OpenACS 5.0.0a4 distribution.
We use the ACS Package Manager (APM) to add, remove, and upgrade packages. It handles package meta-data, such as lists of files that belong in the package. Each package is uniquely identified by a package key. To start developing a new package, use the APM to create an empty package with our new package key, myfirstpackage. This will create the initial directories, meta-information files, and database entries for a new package. (More info on APM)
Browse to http://yourserver:8000/acs-admin/apm.
Click Create a New Package.
Fill in the fields listed below. Tab through the rest. (Some will change automatically. Don't mess with those.)
Package Key: myfirstpackage
Package Name: My First Package
Package Plural: My First Package
Auto-mount URI: myfirstpackage
Initial Version: 0.1d
Summary: This is my first package.
At the bottom, click
.This creates a package rooted at /var/lib/aolserver/service0/packages/myfirstpackage. This is the "home directory" of our new package, and all files in the package will be within this directory.
In order to see your work in progress, you must create a map between the URL space of incoming requests and the package. You do this by mounting the package in the Site Map. This creates a link between the incoming URL and an instance of the package. (More on Site Maps and nodes)
You can have multiple instances of a package on one site, each with a different URL and different permissions, all sharing the same code and tables. This requires that a package be developed package-aware. You'll see how to do that in this tutorial.
Browse to http://yourserver.test:8000/admin/site-map/.
Click the new sub folder link on the top row in the Site Map table.
Type note and click
.This creates a new row called note. In the new row, click the new application link
Type My First Package where it says untitled, choose My First Package from the drop-down list, and click .
By mounting the package, we've caused all requests to http://yourserver.test:8000/myfirstpackage to be satisfied from the files at /var/lib/aolserver/service0/packages/myfirstpackage/www.