Index: openacs-4/packages/acs-core-docs/www/packages.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/packages.html,v diff -u -r1.52 -r1.53 --- openacs-4/packages/acs-core-docs/www/packages.html 7 Aug 2017 23:47:51 -0000 1.52 +++ openacs-4/packages/acs-core-docs/www/packages.html 8 Nov 2017 09:42:11 -0000 1.53 @@ -1,19 +1,35 @@ -OpenACS Packages

OpenACS Packages

By Pete Su and Bryan Quinn

- OpenACS docs are written by the named authors, and may be edited - by OpenACS documentation staff. -

Overview

+OpenACS Packages

OpenACS Packages

+ + + <authorblurb> +

By Pete Su and Bryan Quinn

+ </authorblurb>
+ +

Overview

+ +

This document is a guide on how to write a software package for OpenACS. OpenACS packages are installed and maintained with the OpenACS Package Manager (APM) which is part of the acs-admin package. This document presents reasons for packaging software, conventions for the file system and naming that must be followed, and step by step instructions for creating a new package for the "Notes" example package. -

Server file layout

+

+ +
+ + +

Server file layout

+ +

Here is how an OpenACS 5 server is laid out starting from the Server root (ROOT): -

Figure 11.1. Server file layout diagram

+    

+

Figure 11.1. Server file layout diagram

+ +
 ROOT/
     bin/
         Various executables and scripts for server maintanence.
@@ -31,27 +47,43 @@
     tcl/
         bootstrap code
     www/
-        Pages not in packages (static content, customized pages)

What a Package Looks Like

+ Pages not in packages (static content, customized pages) +


+
+ + +

What a Package Looks Like

+ + +

Each package encapsulates all of its data model, library code, logic, administration pages and user pages in a single part of the file tree. This means developers can track down everything that is related to a particular package without hunting all over the file system. Encapsulating everything about a package in one place also makes it much easier to distribute packages independently from the OpenACS Core. -

+

+ +

In order to make this work, we need a system that keeps track of the packages that have been installed in the server, where those packages have been installed, and a standard way to map URLs that a client sends to our server to the right page in the appropriate package. While we're at it, this tool should also automate package installation, dependency checking, upgrades, and package removal. In OpenACS 5, this tool is called the APM. -

+

+ +

To illustrate the general structure of a package, let's see what the package for the "notes" application should look like. -

Figure 11.2. Package file layout diagram

+    

+ +

Figure 11.2. Package file layout diagram

+ +
 ROOT/
   +-- packages/    APM Root
         |
@@ -108,23 +140,31 @@
         |     |     +-- *.adp                             UI Templates
         |     |     +-- *-oracle.xql                      Oracle-specific Queries
         |     |     +-- *-postgresql.xql                  PostgreSQL-specific Queries
-        +-- Other package directories.

+ +-- Other package directories.

+

+

All file locations are relative to the package root, which in this case is ROOT/packages/notes. The following table describes in detail what each of the files up in the diagram contain. -

+

+ +

A special note on the - PACKAGE-KEY/www/resources + PACKAGE-KEY/www/resources directory. Files in this directory are available at - http://yourserver/resources/PACKAGE-KEY/... + http://yourserver/resources/PACKAGE-KEY/... and are returned without any permissions checking or even checks that the package is installed or mounted. Files are returned directly, so .tcl or .adp files are not sourced in these directories. This makes it suitable for storing icons, css files, javascript, and other static content which can be treated this way. -

Table 11.1. Package files

File TypeIts UseNaming Convention
Package Specification FileThe package specification file is an XML file generated and +

+ +

Table 11.1. Package files

+ +
File TypeIts UseNaming Convention
Package Specification FileThe package specification file is an XML file generated and maintained by the OpenACS Package Manager (APM). It specifies information about the package including its parameters and its files.notes.info
Data Model Creation Script @@ -225,13 +265,25 @@ Templates receive a set of data sources from the logic scripts and prepare them for display to the browser.www/*.adp
UI Index PageThe UI must have an index page composed of a logic script called index.tcl and a template called - index.adp.www/index.tcl

The APM

+ index.adp.

www/index.tcl
+

+ +
+ +

The APM

+ + +

The APM is used to create, maintain, and install packages. It takes care of copying all of the files and registering the package in the system. The APM is responsible for: -

  1. Package registration

  2. Automatic installation of packages: loading data models, code +

    + +
    1. Package registration

    2. Automatic installation of packages: loading data models, code libraries, and so on.

    3. Checking what packages depend on what other packages.

    4. Storing information on the package including ownership and a file - list.

    + list.

+ +

In addition for packages that are applications, the APM is responsible for keeping track of where in the site a user must go in order to use the application. To do this, the APM defines a set of objects that we @@ -243,19 +295,34 @@ running copies of a single program. Each instance can be independently administered and each instance maintains its own set of application parameters and options. -

+

+ +

The following sections will show you how to make a package for the Notes application. In addition, they will discuss some site management features in OpenACS 5 that take advantage of the APM's package instance model. The two most important of these are subsites, and the site map tool, which can be used to map applications to one or more arbitrary URLs in a running site. -

+

+ +

We will also discuss how to organize your files and queries so they work with the OpenACS Query Dispatcher. -

Making a Package

+

+ +
+ + +

Making a Package

+ + + +

Here is how you make a package. -

  1. Login as a site-wide administrator on your web service. +

    + +
    1. Login as a site-wide administrator on your web service.

    2. Go to the package manager on your server. The URL is /acs-admin/apm.

    3. Click on the link /acs-admin/apm/package-add.

    4. Fill out the form for adding a new package. The form explains what @@ -324,7 +391,9 @@ ROOT/packages/notes/sql/postgresql/notes-create.sql and ROOT/packages/notes/sql/postgresql/notes-drop.sql. -

      +

      + +

      After you do this, go back to the main APM page. From there, click the link called "notes" to go to the management page for the new package. Now click the link called "Manage @@ -334,7 +403,9 @@ the file system for new files. This will bring you do a page that lists all the files you just added and lets you add them to the notes package. -

      +

      + +

      Note that while the .sql files have been added to the packge, they have not been loaded into the database. For the purposes of development, @@ -350,7 +421,10 @@ I'll assume that you have set up your development repository according to the standards described in this appendix. If so, then you just do this: -

      % cd ROOT/packages
      +    

      + + +
      % cd ROOT/packages
       % cvs add notes
       % cd notes
       % cvs add notes.info
      @@ -359,10 +433,23 @@
       % cvs add *.sql
       % cd ROOT/packages/notes
       % cvs commit -m "add new package for notes"
      -    
    5. + + + + +

    6. Now you can start developing the package. In addition to writing code, you should also consider the tasks outlined in the package development tutorial. -

The Site Map and Package Instances

+

+ + +
+ +

The Site Map and Package Instances

+ + + +

At this point, you are probably excited to see your new package in action. But, we haven't added any user visible pages yet. By convention, user visible pages go in the @@ -373,7 +460,9 @@ own. What we have to do is mount the application into the site map. That is, we have to define the URL from which the application will serve its pages. -

+

+ +

In OpenACS 5, administrators can define an arbitrary mapping between the URLs the user types and the actual file in the file system that is served. This mapping is called the site map and entries in the @@ -391,7 +480,9 @@ you how OpenACS figures out which instance of your application was requested by the user at any given time. The page development tutorial shows you how to use this information in your user interface. -

+

+ +

In order to make the new notes application visible to users, we have to mount it in the site map. You do this by going to the Site Map page, which is by @@ -400,9 +491,13 @@ the root of the site, then click "new application" to mount a new instance of the notes application to the site. Name the new instance notes-1. -

- Then type this URL into your browser: http://yourserver/notes/hello.html -

+

+ +

+ Then type this URL into your browser: http://yourserver/notes/hello.html +

+ +

Now you should see the contents of the page that you added. What has happened is that all URLs that start with /notes have been mapped in such a way as to serve content from the directory @@ -412,9 +507,19 @@ later document, we'll see how to write your application so that the code can detect from what URL it was invoked. This is the key to supporting subsites. -

Summary

+

+ +
+ +

Summary

+ + + +

The APM performs the following tasks in an OpenACS site: -

  • +

    + +
    • Manages creation, installation, and removal of packages from the server. Also keeps track of what files belong to which packages.

    • @@ -427,4 +532,18 @@

    • Writes out package distribution files for other people to download and install. We'll cover this later. -

+

+ +
+ +

Additional Reading

+ + + + + +

($Id$)

+ +
+ +