Forum OpenACS Q&A: Re: How can I create acs_objects?

Collapse
Posted by Steffen Tiedemann Christensen on
Hey Carlos,

To use the acs_objects table to store your objectt you'll need to set up an object type. For example, if you're storing notes, you'll need to add a note type. Some guidance can be found here.

Then, depending of how strictly you're intending to follow the recommended structure you can add an API for the object type in either plpgsql (see the link) or just do it in tcl. This would usually look something like this:

db_transaction {
  set note_id [db_nextval t_acs_object_id_seq]
  set album_id [db_exec_plsql add_note_object {
            select acs_object__new(
                :note_id,
		'note',
                now(),
                :user_id,
                NULL,
                :user_id,
                TRUE
            );
        }]
  db_dml insert_album {
    insert into my_notes
      (note_id, user_id, title, content, content_format ...)
      values
      (:note_id, :user_id, :title, :content, :content_format ...)
  }
}

Obviously, my_notes.note_id should have a foreign key constraint pointing to acs_objects. And now, you've got yourself an ACS Object which can be used with the permission system etc along with a package specific table for application specific data.

(I should stress, that this approach is probably not the one recommended my most package maintainers in this forum, but it's a nice example of how acs_objects would be used instead of the content repository.)