Index: openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql,v
diff -u -r1.29.2.3 -r1.29.2.4
--- openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql	2 Mar 2003 22:33:33 -0000	1.29.2.3
+++ openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql	5 Mar 2003 14:38:24 -0000	1.29.2.4
@@ -79,16 +79,16 @@
 begin
 -- Create a new object type for packages.
  PERFORM acs_object_type__create_type (
-   ''apm_package'',
-   ''Package'',
-   ''Packages'',
-   ''acs_object'',
-   ''APM_PACKAGES'',
-   ''package_id'',
-   ''apm_package'',
-   ''f'',
-   ''apm_package_types'',
-   ''apm_package.name''
+   ''apm_package'',         -- object_type
+   ''Package'',             -- pretty_name
+   ''Packages'',            -- pretty_plural
+   ''acs_object'',          -- supertype
+   ''APM_PACKAGES'',        -- table_name
+   ''package_id'',          -- id_column
+   ''apm_package'',         -- package_name
+   ''f'',                   -- abstract_p
+   ''apm_package_types'',   -- type_extension_table
+   ''apm_package.name''     -- name_method
    );
 
   return 0;
@@ -293,6 +293,7 @@
     content_length     integer,
     distribution_uri   varchar(1500),
     distribution_date  timestamptz,
+    auto_mount         varchar(50),
     constraint apm_package_vers_id_name_un unique(package_key, version_name)
 );
 
@@ -410,6 +411,12 @@
  When was the distribution tarball downloaded.
 ';
 
+comment on column apm_package_versions.auto_mount is '
+ A dir under the main site site node where an instance of the package will be mounted
+ automatically upon installation. Useful for site-wide services that need mounting
+ such as general-comments and notifications.
+';
+
 -- Metadata for the apm_package_versions object.
 
 create function inline_2 ()
@@ -665,6 +672,31 @@
  manages the order of the authors.
 ';
 
+create table apm_package_callbacks (
+    version_id         integer 
+                       constraint apm_package_callbacks_vid_fk 
+                       references apm_package_versions(version_id)
+                       on delete cascade,
+    type               varchar(40),
+    proc               varchar(300),
+    constraint apm_package_callbacks_vt_un
+    unique (version_id, type)
+);
+
+comment on table apm_package_callbacks is '
+  This table holds names of Tcl procedures to invoke at the time (before or after) the package is
+  installed, instantiated, or mounted.        
+';
+
+comment on column apm_package_callbacks.proc is '
+  Name of the Tcl proc.
+';
+
+comment on column apm_package_callbacks.type is '
+  Indicates when the callback proc should be invoked, for example after-install. Valid
+  values are given by the Tcl proc apm_supported_callback_types.
+';
+
 -- Ths view faciliates accessing information about package versions by joining
 -- the apm_package_types information and acs_object_types information (which is
 -- invariant across versions) with the specific version information.
@@ -674,7 +706,7 @@
     select v.package_key, t.package_uri, t.pretty_name, t.singleton_p, t.initial_install_p,
            v.version_id, v.version_name,
            v.version_uri, v.summary, v.description_format, v.description, v.release_date,
-           v.vendor, v.vendor_uri, v.enabled_p, v.installed_p, v.tagged_p, v.imported_p, v.data_model_loaded_p,
+           v.vendor, v.vendor_uri, v.auto_mount, v.enabled_p, v.installed_p, v.tagged_p, v.imported_p, v.data_model_loaded_p,
            v.activation_date, v.deactivation_date,
            coalesce(v.content_length,0) as tarball_length,
            distribution_uri, distribution_date
@@ -1864,7 +1896,7 @@
 end;' language 'plpgsql';
 
 -- create or replace package body apm_package_version 
-create function apm_package_version__new (integer,varchar,varchar,varchar,varchar,varchar,varchar,timestamptz,varchar,varchar,boolean,boolean) returns integer as '
+create function apm_package_version__new (integer,varchar,varchar,varchar,varchar,varchar,varchar,timestamptz,varchar,varchar,varchar,boolean,boolean) returns integer as '
 declare
       apm_pkg_ver__version_id           alias for $1;  -- default null
       apm_pkg_ver__package_key		alias for $2;
@@ -1876,8 +1908,9 @@
       apm_pkg_ver__release_date		alias for $8;
       apm_pkg_ver__vendor               alias for $9;
       apm_pkg_ver__vendor_uri		alias for $10;
-      apm_pkg_ver__installed_p		alias for $11; -- default ''f''		
-      apm_pkg_ver__data_model_loaded_p	alias for $12; -- default ''f''
+      apm_pkg_ver__auto_mount           alias for $11;
+      apm_pkg_ver__installed_p		alias for $12; -- default ''f''		
+      apm_pkg_ver__data_model_loaded_p	alias for $13; -- default ''f''
       v_version_id                      apm_package_versions.version_id%TYPE;
 begin
       if apm_pkg_ver__version_id is null then
@@ -1899,12 +1932,12 @@
 
       insert into apm_package_versions
       (version_id, package_key, version_name, version_uri, summary, description_format, description,
-      release_date, vendor, vendor_uri, installed_p, data_model_loaded_p)
+      release_date, vendor, vendor_uri, auto_mount, installed_p, data_model_loaded_p)
       values
       (v_version_id, apm_pkg_ver__package_key, apm_pkg_ver__version_name, 
        apm_pkg_ver__version_uri, apm_pkg_ver__summary, 
        apm_pkg_ver__description_format, apm_pkg_ver__description,
-       apm_pkg_ver__release_date, apm_pkg_ver__vendor, apm_pkg_ver__vendor_uri,
+       apm_pkg_ver__release_date, apm_pkg_ver__vendor, apm_pkg_ver__vendor_uri, apm_pkg_ver__auto_mount,
        apm_pkg_ver__installed_p, apm_pkg_ver__data_model_loaded_p);
 
       return v_version_id;		
@@ -1985,10 +2018,10 @@
 
 	insert into apm_package_versions(version_id, package_key, version_name,
 					version_uri, summary, description_format, description,
-					release_date, vendor, vendor_uri)
+					release_date, vendor, vendor_uri, auto_mount)
 	    select v_version_id, package_key, copy__new_version_name,
 		   copy__new_version_uri, summary, description_format, description,
-		   release_date, vendor, vendor_uri
+		   release_date, vendor, vendor_uri, auto_mount
 	    from apm_package_versions
 	    where version_id = copy__version_id;
     
@@ -2001,6 +2034,11 @@
 	    select nextval(''t_acs_object_id_seq''), v_version_id, path, file_type, db_type
 	    from apm_package_files
 	    where version_id = copy__version_id;
+
+        insert into apm_package_callbacks (version_id, type, proc)
+                select v_version_id, type, proc
+                from apm_package_callbacks
+                where version_id = copy__version_id;
     
         if copy__copy_owners_p then
             insert into apm_package_owners(version_id, owner_uri, owner_name, sort_key)
@@ -2015,7 +2053,7 @@
 
 
 -- function edit
-create function apm_package_version__edit (integer,integer,varchar,varchar,varchar,varchar,varchar,timestamptz,varchar,varchar,boolean,boolean)
+create function apm_package_version__edit (integer,integer,varchar,varchar,varchar,varchar,varchar,timestamptz,varchar,varchar,varchar,boolean,boolean)
 returns integer as '
 declare
   edit__new_version_id         alias for $1;  -- default null  
@@ -2028,8 +2066,9 @@
   edit__release_date           alias for $8;  
   edit__vendor                 alias for $9;  
   edit__vendor_uri             alias for $10; 
-  edit__installed_p            alias for $11; -- default ''f''
-  edit__data_model_loaded_p    alias for $12; -- default ''f''
+  edit__auto_mount             alias for $11;
+  edit__installed_p            alias for $12; -- default ''f''
+  edit__data_model_loaded_p    alias for $13; -- default ''f''
   v_version_id                 apm_package_versions.version_id%TYPE;
   version_unchanged_p          integer;       
 begin
@@ -2058,6 +2097,7 @@
 		release_date = date_trunc(''days'',now()),
 		vendor = edit__vendor,
 		vendor_uri = edit__vendor_uri,
+                auto_mount = edit__auto_mount,
 		installed_p = edit__installed_p,
 		data_model_loaded_p = edit__data_model_loaded_p
 	    where version_id = v_version_id;
