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

Hi,

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???) https://openacs.org/doc/object-system-design#object-system-design-api

and

select content_type__create_type followed by
select content_folder__register_content_type
https://openacs.org/doc/tutorial-database

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*

Background:

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,
Ben

Collapse
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 acs_object_type_table.new.

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. https://openacs.org/api-doc/proc-view?proc=group_type::new&source_p=1

best
Brian

Collapse
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.

https://openacs.org/api-doc/plsql-subprogram-one?name=acs_object_type__create_type&type=FUNCTION

https://openacs.org/forums/message-view?message_id=20306
https://openacs.org/forums/message-view?message_id=189562
https://openacs.org/forums/message-view?message_id=3274935

The question is boiling down to:

When to use acs_object_type__create_type vs content_type__create_type ?

Collapse
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.

cheers,
Ben

Collapse
Posted by Benjamin Brink on
This strategy confirmed here: https://openacs.org/doc/search/guidelines
Collapse
Posted by Antonio Pisano on
There exists also another way, that is based on stored procedures. If one look e.g.:

https://openacs.org/api-doc/proc-view?proc=::xo::db::sql::acs_object_type+proc+create_type&source_p=1

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:

define_function_args

Hope this helps

Antonio

Collapse
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.

cheers,
Ben