Forum OpenACS Q&A: Re: New content repository documentation
Great doc, thanks:)
Just fyi, I create my own revisions table and the "x" and "i" views are created for me just fine (I'm on postgres 7.2.4 and OACS 4.6.1).
Also I had some difficulties with integrity constraint violations, etc when I dropped my content types and attributes as well. I have been told they have been fixed in 4.6.3 but just fyi, here is how I delete my content types and attributes:
create function inline_0 ()
returns integer as '
declare
v_rec record;
v_rec_rev record;
begin
-- unregister the mime types
PERFORM content_type__unregister_mime_type (
''orp_ad'', -- content_type
''text/html'' -- mime_type
);
PERFORM content_type__unregister_mime_type (
''orp_ad'', -- content_type
''text/plain'' -- mime_type
);
-- drop the attributes
for v_rec in select attribute_id,attribute_name
from acs_attributes
where object_type = ''orp_ad''
LOOP
PERFORM cmsf_attributes__unregister_widget (
v_rec.attribute_id
);
PERFORM cmsf_attributes__drop_attribute (
''orp_ad'',
v_rec.attribute_name
);
end LOOP;
return null;
end;' language 'plpgsql';
select inline_0();
drop function inline_0 ();
create function inline_0 ()
returns integer as '
declare
v_rec record;
v_rec_rev record;
begin
-- Delete personal ads themselves, created in CR.
-- Temporary workaround (fixed in OACS 4.6.3) for:
-- ERROR: Referential Integrity: attempting to delete latest_revision:
-- from content_item__delete() function.
UPDATE cr_items set latest_revision = null where content_type = ''orp_ad'';
-- Temporary workaround (fixed in OACS 4.6.3)
-- We don not have to delete revisions first in 4.6.3.
-- But for now, content_item__delete errors if revisions exist so we do them first.
-- Remove content_type content revisions.
for v_rec in select item_id
from cr_items
where content_type = ''orp_ad''
LOOP
for v_rec_rev in select revision_id
from cr_revisions
where item_id = v_rec.item_id
LOOP
PERFORM content_revision__delete (
v_rec_rev.revision_id
);
end LOOP;
end LOOP;
return null;
end;' language 'plpgsql';
select inline_0();
drop function inline_0 ();
-- Splitting content_items into separate function
-- seems to have fixed this error:
-- ERROR: cr_items_rev_type_fk referential integrity violation - key referenced from cr_items not found in acs_object_types
-- whatever;(
create function inline_0 ()
returns integer as '
declare
v_rec record;
v_rec_rev record;
begin
-- Remove content_type content items.
for v_rec in select item_id
from cr_items
where content_type = ''orp_ad''
LOOP
RAISE NOTICE ''BEGIN Deleting content item %'',v_rec.item_id;
PERFORM content_item__delete (
v_rec.item_id
);
RAISE NOTICE ''END Deleting content item %'',v_rec.item_id;
end LOOP;
return null;
end;' language 'plpgsql';
select inline_0();
drop function inline_0 ();