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


I want to use acs_objects instead of cr_items because I don´t need the stuff related to item revisions. I've looked for procs in the api but I found nothing.
Can you give me any hints to do it?


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(
  db_dml insert_album {
    insert into my_notes
      (note_id, user_id, title, content, content_format ...)
      (: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.)

Posted by Steffen Tiedemann Christensen on
(and obviously, all my references to album/albums should be replaced with note/notes; copying and pasting examples is never a good idea)