Forum OpenACS Q&A: Defining a skinny, new acs-object type
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
select content_type__create_type followed by
grepping code in packages seems to suggests a more popular alternate:
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.
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
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 ?
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
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.