Forum OpenACS Q&A: Defining a skinny, new acs-object type

Request notifications

Posted by Benjamin Brink on

Is there a way to define a new acs_object type using the tcl api?

The case is for making new object_ids with new object types but without any additional attributes. Each object_id represents a fluid set of objects unconstrained to openacs-core data model.

If no tcl api exists is there any reason one shouldn't be created for this task? ie is there any reason to not put the PL/SQL in a db_dml statement in a tcl proc in a package-init.tcl file, where the PL/SQL is only executed if the object_type doesn't exist?

If a tcl proc is not recommended/possible etc, what is the preferred way to define a new acs_object_type?

There appears to be at least these three approaches (one maybe Oracle PL/SQL, the other Pg PL/SQL, and the other ?):

Call acs_object_type.create_type() (in what context???)


select content_type__create_type followed by
select content_folder__register_content_type

and yet,

grepping code in packages seems to suggests a more popular alternate:

select acs_object_type__create_type
and *no* use of an acs_object_type__register*


Some packages are using a simple role-based-access-control permissions system (q-control) with unit tests to show full integrity. RBAC is a subset of OpenACS's permissions capabilities.

q-control may be a useful way to translate commonly used RBAC permissions paradigms to OpenACS permissions, and that q-control's unit tests provides a framework to copy for testing OpenACS permissions in an RBAC configuration.

Thank you,

Posted by Brian Fenton on
Hi Benjamin!

we use the PL/SQL procedure acs_object_type.create_type all the time (we're an Oracle shop) to create new object types.

We usually also use

There is no TCL API that I'm aware of. group_type::new does use the acs_object_type.create_type API so that might be a starting point.


Posted by Benjamin Brink on
Thank you, Brian. I'm sure that will work.

It's just odd to see a different (seemingly more general) paradigm of acs_object_type__create_type in practice instead of the one in the tutorial / doc. And it appears to have been around since circa 2000, but the only documentation appears to be in api-doc's PL/SQL section.

The question is boiling down to:

When to use acs_object_type__create_type vs content_type__create_type ?

Posted by Benjamin Brink on
Since the content repository (content_type__create_type etc) has lots of extra features that are not needed in a skinny object, I'm going to try following the acs_object_type__create_type examples for now.


Posted by Benjamin Brink on
This strategy confirmed here:
Posted by Antonio Pisano on
There exists also another way, that is based on stored procedures. If one look e.g.:

This is another tcl way to build a new acs_object type.

This kind of procs in the ::xo::db::sql namespace are automatically created at startup for every proc defined in the acs_function_args table. One way to see how this machinery works is grepping in the sql code for:


Hope this helps


Posted by Benjamin Brink on
Thank you, Antonio. Very interesting.

Next-Scripting is such a tease. The number of lines of code will likely be reduced by a factor of twenty or more when refactoring my project using it.