Forum OpenACS Q&A: Generalized Partial Order Manipulation For ACS Objects?

After having read the documentation on ACS objects (well more or less)
and scanning through the source code for acs_object and for that
matter the source contained in postgres.sql (more or less), it's still
not clear to me whether it's already built into acs_object the
facility to manipulate partial orders (i.e. trees).  There seems to be
highly optimized code to modify tree_sortkey, but on the other hand,
there does not exist a simple function like acs_object__set_parent()
or acs_object__add_child() or anthing with a name that would obviously
imply such functionality.  Additionally, there's nothing in the
documentation of ACS object that says plainly "supports partial order
relationships," but from what I've heard, that's to be expected since
the documenation is way out of date.

So, what is tree_sortkey used for?  What could it be used for?  Is one
supposed to use the general relationship support instead?  How
optimized would that be?  How about using attributes?

Looking for a little -- no scratch that a lot of -- direction here.

-Jeff

Basic ACS Objects aren't ordered in any sense. Object types have an inheritance association, of course, but objects themselves don't.

The tree sortkey you see in the ACS Objects table is used to track the permissions inheritance tree, linked through the context_id field . In the PG version the context_id field isn't actually needed (the tree sortkeys encode the same information as you'd get by chasing the context_id field). However in Oracle we actually do chase context_id using CONNECT BY queries. In order to standardize APIs and maintain as many queries as possible in common we maintain context_id and manipulate the tree sortkey in PG via the triggers you see in the datamodel.

Certain object types are mapped to a tree, in particular content types (see acs-content-repository). These types (and types derived from these types) are ordered into a folder/object style hierarchy. The content types have an additional tree sortkey which encode the relationship of the content object to other content objects in the system.