Powered by Max Banner Ads
By Jon Griffin
Introduction
This document is a method for creation and understanding the OpenACS framework. It is mostly my methodology with input from the OpenACS community.This is not a beginning tutorial on programming. Many other sources exist for this like openacs.org.
Philosophy
We will use several packages to explain the general programming concepts of openACS.
File Layout
packages/package-name
sql/db
postgresql
package-name-create.sql
Header
The header should contain the following:
-- packages/meeting-minutes/sql/postgresql/meeting-minutes-details-create.sql
--
-- @author jon@jongriffin.com
-- @creation-date 2001-03-27
-- @cvs-id $Id: programmers-guide.html,v 1.1 2003/03/24 06:35:01 jon Exp $
-- updated for openACS 05/2002 jon@jongriffin.com
Comments are of course more than welcome. –link to file
Permissions
lookup tables
These are tables that are local to the package and don’t need to be acs_objects.
-- lookup table for Item Numbers -- we store these here because most meetings have -- the same items create table meeting_item_numbers ( item_id integer constraint meeting_item_numbers_pk primary key, description varchar(50) ); -- a general sequence for meetings tables create sequence meeting_general_seq;
Probably we should make the update/delete etc in plsql also.
Main Tables
comments
comment on table meeting_minutes is '
This is the master meeting list.
';
comment on column meeting_minutes.meeting_date is '
The date of the meeting.
';
acs_object_type
new,del,update
oracle
Appendix
Core db procs
acs_object new() delete()
Common Problems
plpgsql is tough to debug:
create function meeting_minutes_track__new (integer,varchar,integer,varchar,
integer,varchar,integer)
returns integer as '
declare
p_admin_user alias for $1;
p_title alias for $2;
p_track_id alias for $3; -- default null
p_object_type alias for $4; -- default acs_object
p_creation_user alias for $5; -- default null
p_creation_ip alias for $6; -- default null
p_context_id alias for $7; -- default null
v_track_id meeting_minutes_tracks.track_id%TYPE;
begin
v_track_id := acs_object__new (
p_track_id,
p_object_type,
now(),
p_creation_user,
p_creation_ip,
p_context_id
);
insert into meeting_minutes_tracks
(admin_user, title, track_id)
values
(admin_user, title, v_track_id);
-- Permissions
PERFORM acs_permission__grant_permission(
v_track_id,
p_user_id,
''admin''
);
return v_track_id;
end;' language 'plpgsql';
The problem here was that when I ported the proc, I changed to the new OpenACS style and forgot to add the p_ to my values in the insert. The only way in PG to debug this was to run psql and manually replace the bind vars:
mayuli=# select meeting_minutes_track__new (
2424, -- admin user is null for now
'Test Track',
null,
'meeting_minutes_track', -- object_type defaults to the right thing
2424,
'111.111.1.1',
3104
);
This allowed me to finally see the error that the page wouldn’t show in the browser
mayuli(# ERROR: Attribute 'admin_user' not found
Templates make sure you don’t have any characters after the element create line continuation or you will be sorry
plsql
Make sure you don’t accidently create a constant in your plsql.
My original bad way:
v_object_type acs_objects.object_type%TYPE;
begin
if p_object_type is null then
p_object_type := ''meeting_minute'';
end if;
The following is the right way:
v_object_type acs_objects.object_type%TYPE;
begin
if p_object_type is null then
v_object_type := ''meeting_minute'';
else
v_object_type := p_object_type;
end if;

This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.

