previo | siguiente

How to create a new acs_object type


New acs_object types are derived from an existing acs_object type (often the root object type, acs_object, itself).

Currently, creating an object requires direct calls to PL/[pg]SQL. In other words, you must provide calls in the package's sql/oracle and sql/postgresql subdirectories. In the future (OpenACS 5.1 or, more likely, 5.2) we will support creation of objects from a high-level Tcl API, which will require much less coding.

The basic steps in PostgreSQL, in order, are ...

  • Create the SQL table which will hold the data required by your new acs_object type. By convention, the table holding the data for type foo is named foos, and has a primary key declared foo integer primary key references acs_objects.

  • Call acs_object__create_type() to create the type in the OpenACS object type datamodel.

  • Call acs_object__create_attribute() to create the attributes ("columns" in SQL-speak).

  • Create new and del functions (foo__new() and foo_del for our example type foo). Use "define_function_args()" to store metadata about the parameter lists for these procedures (use "grep" to find examples).

In Oracle, you should define a package with the same name as your acs_object type containing the new and del functions. Since Oracle makes function parameter list metadata available through documented SELECT statements, there is no "define_function_args()" procedure in the Oracle version of OpenACS.

Don Baccus (dhogaza@pacifier.com)

Don Baccus (dhogaza@pacifier.com)