Forum OpenACS Development: Response to content_revision deleting
Posted by
Dan Wickstrom
on 10/23/01 06:33 PM
There must be something else involved here. The deletion of content folders seems to work fine. Here is a test case where I create a folder with a content item. I then set the revision of the content item live, and then I delete the content item and its folder in one step using a pl/pgsql function.
openacs4=# select * from cr_items; item_id | parent_id | name | locale | live_revision | latest_revision | publish_status | content_type | storage_type | storage_area_key | tree_sortkey ---------+-----------+------------------+--------+---------------+-----------------+----------------+------------------+--------------+------------------+-------------- -100 | 0 | pages | | | | | content_folder | text | CR_FILES | /00 -200 | 0 | templates | | | | | content_folder | text | CR_FILES | /01 991 | -200 | default_template | | 992 | 992 | | content_template | text | CR_FILES | /01/00 2458 | -100 | test folder | | | | | content_folder | text | CR_FILES | /00/00 2459 | 2458 | simple item | | 2461 | 2462 | ready | content_revision | text | CR_FILES | /00/00/00 (5 rows) And here is the deletion function: create function delete_test_folder(integer) returns integer as ' declare folder_id alias for $1; v_rec record; begin for v_rec in select item_id from cr_items where parent_id = folder_id LOOP PERFORM content_item__delete(v_rec.item_id); end LOOP; PERFORM content_folder__delete(folder_id); return null; end;' language 'plpgsql'; Here is the folder and its content item being deleted: openacs4=# select delete_test_folder(2458); NOTICE: Deleting symlinks... NOTICE: Unscheduling item... NOTICE: Deleting associated revisions... NOTICE: Deleting associated item templates... NOTICE: Deleting item relationships... NOTICE: Deleting child relationships... NOTICE: Deleting parent relationships... NOTICE: Deleting associated permissions... NOTICE: Deleting keyword associations... NOTICE: Deleting associated comments... NOTICE: identifier "journal_entry__delete_for_object" will be truncated to "journal_entry__delete_for_objec" NOTICE: Deleting content item... NOTICE: identifier "content_folder__unregister_content_type" will be truncated to "content_folder__unregister_cont" NOTICE: Deleting symlinks... NOTICE: Unscheduling item... NOTICE: Deleting associated revisions... NOTICE: Deleting associated item templates... NOTICE: Deleting item relationships... NOTICE: Deleting child relationships... NOTICE: Deleting parent relationships... NOTICE: Deleting associated permissions... NOTICE: Deleting keyword associations... NOTICE: Deleting associated comments... NOTICE: Deleting content item... delete_test_folder -------------------- (1 row) And here is cr_items afterwards: openacs4=# select * from cr_items; item_id | parent_id | name | locale | live_revision | latest_revision | publish_status | content_type | storage_type | storage_area_key | tree_sortkey ---------+-----------+------------------+--------+---------------+-----------------+----------------+------------------+--------------+------------------+-------------- -100 | 0 | pages | | | | | content_folder | text | CR_FILES | /00 -200 | 0 | templates | | | | | content_folder | text | CR_FILES | /01 991 | -200 | default_template | | 992 | 992 | | content_template | text | CR_FILES | /01/00 (3 rows)As you can see, there is no problem with deleting the folder. Are you sure the there is nothing else in the CR that has your folder as its parent? What is in cr_items before you try to delete the folder?