Forum OpenACS Development: Re: relational segments: how do you use them
"registered_users" is a group, not a relseg. The relseg I alluded to was "Main Site Members" which is related to this group. The call to membership_rel__new() (which is specific to the "membership_rel" relation type) creates a "relation" between the user and the group, as you say. Only indirectly does it make the user a *member* of the group and associated relsegs:
membership_rel__new() also inserts a row into the "membership_rels" table and there's an insert trigger on that table ("membership_rels_in_tr"). Among other things, this trigger calls party_approved_member__add() - if new.member_state is "approved", that is. party_approved_member__add() basically inserts into party_approved_member_map, both for the group in question and for any relational segment(s) that the relation type may be mapped to.
That is how the newly created user becomes a member of the "Registered Users" group and "Main Site Members" segment.
Evidently, although I havent looked for it, there must be a relational segment already defined in an earlier step in the default installation that goes under the name "Main Site Members", is associated with group -2 ("Registered Users"), and holds relations of the basic type "membership_rel".
It is the fact that there existed a relseg (which was associated with the group and relation type in question) in the first place, that made the user a (approved) member of the relseg, too, and not only of the group.
Does this make sense?
As a side note, there seems to be a rather ample supply of Tcl procs that handle these type/group/segment/relation issues. By using them we may avoid writing separate sets of Pl[Pg]SQL code for Oracle and PostgreSQL in our applications... (Now that we have a good support for APM Tcl callbacks, I mean.)