Forum OpenACS Development: CR, content_item_new and context_id questions

I have run into some problems while exploring the CR, in particular with respect to context_id.

There are two custom content types, cu_sequence and cu_activity, which I want to use in the following way:

There will be a tree of "activities" where the root activity has a "sequence" item as its parent. The problem is that, when I add a child activity item, regardless of which of the two types the parent is, the context_id of the child item gets set to the same value as its own item_id - even when I provide content_item__new with $sequence_id as p_context_id (I use the version of content_item__new that takes 16 params).

Is this the intended/correct way of things? It makes it a little difficult to scope the activities in the tree to the parent sequence. That sequence_id was what I was hoping to use as the context for all the children in that particular activity tree, since there can be several trees (with different parent sequences) living in parallel - all of which should be able to be displayed separately.

I hope that the snippet below shows what I mean.

I guess the real question is; what is the preferred way of setting the context_id explicitly, and, is this a bug?

Perhaps it would be better of me to use a separate extended attribute, "sequence_id", to the attributes table for my content type, i.e., the cu_activities table?

BTW, when using CR, what would seem the most standardized way to name url vars; ?item_id=1234 vs. ?sequence_id=1234, etc...?

select name, object_type, context_id, item_id, parent_id
from   cr_revisionsx
where  item_id in (2853, 2855, 2864);

      name      | object_type | context_id | item_id | parent_id 
----------------+-------------+------------+---------+-----------
 TEST SEQUENCE  | cu_sequence |       2853 |    2853 |      -100
 ROOT ACTIVITY  | cu_activity |       2855 |    2855 |      2853
 CHILD ACTIVITY | cu_activity |       2864 |    2864 |      2855
(3 rows)
Collapse
Posted by Dave Bauer on
OLa,

Context_id is only for the permissions hierarchy.

I think what you want if you are using the CR is either parent_id of the content_item, or to build your own hierarchy in the custom content_type table itself. So your application should not be using context_id to represent the physical relationship of the items in a tree. You might even want to generate your own tree_sortkey for your content_type, although if you use parent_id in the CR, you can use the cr_items tree_sortkey column.

That said, you should be able to set the context_id with the pl/pgsql functions, I'd have to look at the source to see why it isn't working.

Ola, in general you'd want to refer to the item_id in the URL. It doesn't matter what you call it in the URL, but unless you want to access revisions, you usually will reference the item_id and query for the live revision in the page.

Collapse
Posted by Ola Hansson on
There are two versions of content_item__new that takes 16 params...

I use the one that has a locale attribute and doesn't have a security_inherit_p attrib.

I note that security_inherit_p defaults to 't' when acs_object__new is called without that param, which is the case with the version of content_item__new I use.
I wonder if setting security_inherit_p to 'f' would get me what I talked about before?

(Not that I'm thinking of misusing the context_id to represent hierarchy or scope now that you'we enlightened me about its intended use!)

While I'm on to this topic: Is the version with the "locale" param more suitable than the other in terms of internationalization of the CR contents?