Forum OpenACS Development: Problems with acs-content-repository content_folder and content_type

Hi everyone Well I am still getting the errors regarding the plpgsql error messages for the data models and thought I would post some more info to see if I am missing something. The package I am working on is the wp-slim one and I am having a couple of nagging problems with the drop file for the datamodel. These problems all have to do with the acs-content-repository which has commands for content_type__drop_attribute and content_folder__unregister_content_type. Firstly the content_folder__unregister_content_type preoblem: CODE:
 
create function inline_7 ()
returns integer as'
begin
  PERFORM
content_folder__unregister_content_type(content_item_globals.c_root_folder_id,''cr_wp_presentation'',''f'');
  PERFORM
content_folder__unregister_content_type(content_item_globals.c_root_folder_id,''cr_wp_presentation_audience'',''f'');
  PERFORM
content_folder__unregister_content_type(content_item_globals.c_root_folder_id,''cr_wp_presentation_background'',''f'');
  PERFORM
content_folder__unregister_content_type(content_item_gloabals.c_root_folder_id,''cr_wp_slide'',''f'');
  PERFORM
content_folder__unregister_content_type(content_item_globals.c_root_folder_id,''cr_wp_slide_preamble'',''f'');
  PERFORM
content_folder__unregister_content_type(content_item_gloabals.c_root_folder_id,''cr_wp_slide_postamble'',''f'');
  PERFORM
content_folder__unregister_content_type(content_item_gloabals.c_root_folder_id,''cr_wp_slide_bullet_items'',''f'');
return 0;
end;' language 'plpgsql';   
select inline_7 ();
drop function inline_7 ();
ERROR MESSAGE:
psql:wp-slim-drop1.sql:170: NOTICE:  identifier
"content_folder__unregister_content_type" will be truncated to
"content_folder__unregister_cont"
psql:wp-slim-drop1.sql:170: NOTICE:  plpgsql: ERROR during compile of
content_folder__unregister_cont near line 35
psql:wp-slim-drop1.sql:170: ERROR:  parse error at or near ";"

I have tried everything I could think of but nothing seems to fix up this problem. now the content_type__drop_attribute problem CODE:
create function inline_9 ()
returns integer as'
begin
  PERFORM
content_type__drop_attribute(''cr_wp_presentation'',''pres_title'',''f'');
  PERFORM
content_type__drop_attribute(''cr_wp_presentation'',''page_signature'',''f'');
  PERFORM
content_type__drop_attribute(''cr_wp_presentation'',''copyright_notice'',''f'');
  PERFORM
content_type__drop_attribute(''cr_wp_presentation'',''style'',''f'');
  PERFORM
content_type__drop_attribute(''cr_wp_presentation'',''public_p'',''f'');
  PERFORM
content_type__drop_attribute(''cr_wp_presentation'',''show_modified_p'',''f'');

  PERFORM
content_type__drop_attribute(''cr_wp_slide'',''sort_key'',''f'');
  PERFORM
content_type__drop_attribute(''cr_wp_slide'',''slide_title'',''f'');
  PERFORM
content_type__drop_attribute(''cr_wp_slide'',''include_in_outline_p'',''f'');
  PERFORM
content_type__drop_attribute(''cr_wp_slide'',''context_break_after_p'',''f'');
  PERFORM
content_type__drop_attribute(''cr_wp_slide'',''style'',''f'');
return 0;
end;' language 'plpgsql';
select inline_9 ();
drop function inline_9 ();

ERROR MESSAGE:

psql:wp-slim-drop1.sql:205: NOTICE:  plpgsql: ERROR during compile of
content_type__drop_attribute near line 24
psql:wp-slim-drop1.sql:205: ERROR:  parse error at or near
"content_type"
I really dont know what is wrong and would appreciate some help. Thanks Jack
change the following code in content_type__drop_attribute from:

  if NOT FOUND then
    raise EXCEPTION ''-20000: Attribute %:% does not exist in content_type.drop_attribute'', content_type, attribute_name;
  end;

To:

  if NOT FOUND then
    raise EXCEPTION ''-20000: Attribute %:% does not exist in content_type.drop_attribute'', drop_attribute__content_type, drop_attribute__attribute_name;
  end;

One other thing to note about this routine is that postgresql doesn't support alter table drop column, so when you drop a type attribute, the column will be left hanging around in the type attribute table. AFAIK there isn't a good work-around for this problem.

I'm unable to reproduce you're content_folder__unregister_content_type problem:

openacs4=# select * from cr_folder_type_map;
 folder_id |   content_type   
-----------+------------------
      -100 | content_revision
      -100 | image
      -100 | content_folder
      -100 | content_symlink
      -200 | content_folder
      -200 | content_symlink
      -200 | content_template
      2201 | content_folder
      2201 | content_revision
      2201 | content_symlink
      2201 | image
      2202 | content_folder
      2202 | content_revision
      2202 | content_symlink
      2202 | image
      2203 | content_folder
      2203 | content_revision
      2203 | content_symlink
      2203 | image
      2204 | content_folder
      2204 | content_revision
      2204 | content_symlink
      2204 | image
(23 rows)

openacs4=# select content_folder__unregister_content_type(2204,'content_folder','f');
NOTICE:  identifier "content_folder__unregister_content_type" will be truncated to "content_folder__unregister_cont"
 content_folder__unregister_cont 
---------------------------------
                               0
(1 row)

openacs4=# select content_folder__unregister_content_type(2204,'content_revision','t');
NOTICE:  identifier "content_folder__unregister_content_type" will be truncated to "content_folder__unregister_cont"
 content_folder__unregister_cont 
---------------------------------
                               0
(1 row)

openacs4=# 

When was the last time that you updated from cvs?

It has definitely been a while since we installed the packages. I have tried looking for information on just how to go about upgrading my copy but cannot fnd anything to help me out. I did find some vague comments but I have tried to the best of my abilities and nothing works.

I tried to download just the acs-content-repository packagae using the method suggested in the documentation... but I dont think I have a user name that fits into the mailto:username@openacs.org category.

Would you be able to tell me how to go about upgrading from the cvs?

Thanks again
Jack

Here's a document on how to checkout the latest sources from cvs.
Your user name is "jackp".  Go to your <acs-root>/packages directory and do this:

cvs -d mailto:jackp@openacs.org:/cvsroot update .

Your password should be the same as your http://openacs.org (i.e. OpenACS) password.  If that doesn't work e-mail me.

Now ... the above update may fail if you previously did a cvs checkout
using anonymous pserver.  CVS seems to get confused if you mix and match Roots, at least it has in the past for me.

In that case you probably want to checkout a new copy somewhere using your account and move your work over there.  There's probably a smart way to fix it but I've not looked into it ...

Don,

From a somewhat dim memory (!), the "smart" way you mention is probably editing your local CVS/Root file to contain the new info about your changed access to the repository?

Hi Dan I have just updated the database and yes it has removed one of the problems... the one dealing with the content_folder... But it has changed the error message for the content_type__drop_attribute command. The Error Message now is:
psql:wp-slim-drop1.sql:61: NOTICE:  plpgsql: ERROR during compile of content_type__drop_attribute near line 28
psql:wp-slim-drop1.sql:61: ERROR:  parse error at or near ";"
And the wp-slim code is:

create function inline_3 ()
returns integer as'
begin
  PERFORM content_type__drop_attribute(''cr_wp_attachment'', ''display'',''f'');return 0;
end;' language 'plpgsql';
select inline_3 ();
drop function inline_3 ();

I have checked the content_type__drop_atribute code and changed it as you instructed. It now looks like this:

  if NOT FOUND then
    raise EXCEPTION ''-20000: Attribute %:% does not exist in content_type.drop_attribute'', drop_attribute__content_type, drop_attribute__attribute_name;
  end;

I really dont know where to go from here and would appreciate any ideas on what I am supposed to do. Thanks again... your help is much appreciated Jack
Ok, I found and fixed a couple more bugs in that routine. One of them is the if statement. It should end in "end if" instead of "end". The other is the boolean used to disable the drop column command. pg is unable to resolve the ''f'' value to a boolean so I added a cast.

I also stumbled across an inherit flaw in the design of the content_type__refresh_view routine. It turns out that a content type table can have column names that match the default columns in the type input view. When the view is refreshed, two columns can have the same name which will cause the view creation to fail. I noticed this while trying to drop a column from 'publishing_wf'.