Index: openacs-4/packages/edit-this-page/sql/postgresql/edit-this-page-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/sql/postgresql/edit-this-page-create.sql,v
diff -u -N -r1.9 -r1.10
--- openacs-4/packages/edit-this-page/sql/postgresql/edit-this-page-create.sql	21 Dec 2002 22:29:10 -0000	1.9
+++ openacs-4/packages/edit-this-page/sql/postgresql/edit-this-page-create.sql	4 Apr 2003 15:58:13 -0000	1.10
@@ -39,26 +39,28 @@
   p_content_type alias for $4;  -- default null -> use content_revision
   v_item_id integer;
   v_revision_id integer;
-  v_content_type varchar;
   v_folder_id integer;
 begin
   v_item_id := acs_object__new(null, ''content_item'', now(), null, null, p_package_id);
 
   v_folder_id := etp__get_folder_id(p_package_id);
 
+-- due to a change in acs_object__delete we can reference the actual
+-- object type we want
+-- using this we can more easily search, but we will have to create a service
+-- contract for each custom content type
+-- we define a default etp_page_revision and service contract to go with it
+-- make sure to subtype from etp_page_revision for any custom types
+-- 2003-01-12 DaveB
+
   insert into cr_items (
     item_id, parent_id, name, content_type
   ) values (
-    v_item_id, v_folder_id, p_name, v_content_type
+    v_item_id, v_folder_id, p_name, p_content_type
   );
 
-  -- would like to use p_content_type here, but since there''s 
-  -- no table that corresponds to it, we get an error from
-  -- the dynamic sql in acs_object__delete.  so just use content_revision.
+  v_revision_id := acs_object__new(null, p_content_type, now(), null, null, v_item_id);
 
-  v_content_type := ''content_revision'';
-  v_revision_id := acs_object__new(null, v_content_type, now(), null, null, v_item_id);
-
   insert into cr_revisions (revision_id, item_id, title, 
                             publish_date, mime_type) 
   values (v_revision_id, v_item_id, p_title, now(), ''text/html'');
@@ -303,7 +305,7 @@
     select target_id into v_item_id
       from cr_symlinks
      where symlink_id = p_item_id;
-    return etp__get_title(p_item_id, null);
+    return etp__get_title(v_item_id, null);
   end if;
 
   if v_object_type = ''content_item'' then
@@ -357,7 +359,7 @@
     select target_id into v_item_id
       from cr_symlinks
      where symlink_id = p_item_id;
-    return etp__get_description(p_item_id, null);
+    return etp__get_description(v_item_id, null);
   end if;
 
   if v_object_type = ''content_item'' then
@@ -448,3 +450,17 @@
 
 select inline_1 ();
 drop function inline_1 ();
+
+-- create a default content_type etp_page_revision
+-- DaveB
+-- this references a non-existant table
+-- which I might have to change...
+select content_type__create_type (
+        'etp_page_revision',        -- content_type
+	'content_revision',         -- supertype
+	'ETP managed page',       -- pretty_name
+	'ETP managed pages',      -- pretty_plural
+	'etp_page_revisions',            -- table_name
+	'etp_page_revision_id',              -- id_column
+	'content_revision__revision_name'  -- name_method
+);
