Index: openacs.org-dev/packages/edit-this-page/sql/postgresql/edit-this-page-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/edit-this-page/sql/postgresql/edit-this-page-create.sql,v
diff -u -r1.1 -r1.2
--- openacs.org-dev/packages/edit-this-page/sql/postgresql/edit-this-page-create.sql	9 Jul 2002 17:35:08 -0000	1.1
+++ openacs.org-dev/packages/edit-this-page/sql/postgresql/edit-this-page-create.sql	23 Nov 2002 04:33:03 -0000	1.2
@@ -29,7 +29,7 @@
 ' language 'plpgsql';
 
 
-
+--drop function etp__create_page(integer, varchar, varchar, varcahr);
 create function etp__create_page(integer, varchar, varchar, varchar)
 returns integer as '
 declare
@@ -42,30 +42,59 @@
   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_item_id := acs_object__new(null, ''content_item'', now(), null, null, p_package_id);
 
   v_folder_id := etp__get_folder_id(p_package_id);
 
-  insert into cr_items (
-    item_id, parent_id, name, content_type
-  ) values (
-    v_item_id, v_folder_id, p_name, v_content_type
-  );
+--  insert into cr_items (
+--    item_id, parent_id, name, content_type
+--  ) values (
+--    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.
+  -- DaveB: i fixed acs_object__delete to check for existance of table
+  -- before deleting so we can use the real content type
 
-  v_content_type := ''content_revision'';
-  v_revision_id := acs_object__new(null, v_content_type);
+--  v_content_type := ''content_revision'';
+--  v_revision_id := acs_object__new(null, p_content_type);
+--
+--  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'');
+--
+--  update cr_items set live_revision = v_revision_id
+--                  where item_id = v_item;
 
-  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'');
+   v_item_id := content_item__new(
+		v_name,
+		v_folder_id,
+		NULL,
+		NULL,
+		current_timestamp,
+		null,
+		null,
+		null,
+		''content_item'',
+		''etp_page_revision'',
+		NULL,
+		NULL,
+		''text/html'',
+		NULL,
+		''text'
+		);
 
-  update cr_items set live_revision = v_revision_id
-                  where item_id = v_item_id;
-
+   v_revision_id := content_revision__new(
+		 NULL,
+		 NULL,
+		 current_timestamp,
+		 ''text/html'',
+		 NULL,
+		 v_item_id
+		 );
+	 
   return 1;
 end;
 ' language 'plpgsql';
