Index: openacs-4/packages/acs-content-repository/www/doc/guide/storage.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/www/doc/guide/storage.adp,v diff -u -N -r1.4.2.2 -r1.4.2.3 --- openacs-4/packages/acs-content-repository/www/doc/guide/storage.adp 3 Sep 2021 09:14:42 -0000 1.4.2.2 +++ openacs-4/packages/acs-content-repository/www/doc/guide/storage.adp 13 Jul 2023 12:47:28 -0000 1.4.2.3 @@ -18,18 +18,21 @@
Most types of content require additional attributes. For a photo, we probably also want to store the pixel width and height at the very least:
-create table images ( ++ create table images ( image_id integer constraint images_image_id_fk references cr_revisions constraint images_pk primary key, width integer, height integer - );+ ); +
Content types are nothing more than standard ACS Objects that inherit from content_revision:
-begin ++begin acs_object_type.create_type ( supertype => 'content_revision', @@ -59,7 +62,8 @@ end; / -show errors+show errors +
Note that content types always extend content_revision, rather than content_item. This is because we want to store multiple revisions of both the @@ -75,7 +79,8 @@
In the simple case where each user is allowed a single portrait, we can simply define a relationship between user and image as ACS Objects:
-acs_rel_type.create_role('user'); ++ acs_rel_type.create_role('user'); acs_rel_type.create_role('portrait'); acs_rel_type.create_type( rel_type => 'user_portrait_rel', @@ -88,7 +93,8 @@ object_type_two => 'content_item', min_n_rels_two => 0, max_n_rels_two => 1 - );+ ); +
Note that the user object is related to a content_item object rather than an image object directly. Each image object represents only a @@ -98,16 +104,20 @@
Now we have defined both a content type and relationship type, we can start storing portraits. The DML for processing a new portrait upload form would look like this:
-begin transaction ++ begin transaction :item_id := content_item.new(:name, :item_id, sysdate, NULL, '[ns_conn peeraddr]'); # maybe have content_revision return the LOB locator so that it can # be used directly with blob_dml_file :revision_id := content_revision.new(:title, :description, $publish_date, :mime_type, NULL, :text, 'content_revision', :item_id, :revision_id); blob_dml_file update cr_revisions set content = empty_blob() ... - :rel_id := acs_rel.new(...)+ :rel_id := acs_rel.new(...) +
ns_ora write_blob ...+
+ ns_ora write_blob ... +
Last Modified: $Id: storage.html,v 1.2.2.1 2021/04/05 19:49:49