Forum OpenACS Q&A: Which parameters/values must be passed to content::revision::new?

Hi all,

i like to change the description of an item and a line like

content::revision::new -item_id $the_id -attributes [list [list description $new_description]]

caused an error: Transaction aborted: Database operation "0or1row" failed (exception ERROR, "ERROR: null value in column "status_id" violates not-null constraint CONTEXT: SQL statement "insert into pm_projects ( project_id, pm_finished_p, and so on.

As the API browser said, everything is optional except of the item_id, i assumed that all values in the revision will stay the same, except the new given values.

Questions:
- Have i to pass ALL current values?
- Are switches like title and description identical with the fields in the database table?
  - If yes, is there a difference in passing a field by switch or in the list of the attributes switch?

TIA,
Nils

Yes, you need to pass in all the attributes. It does now "know" about previous revisions so you need to pass in all the attributes, content::revision::new does not copy from a previous revision.
Hi Dave,

thank you for your answer.

It does now "know" or it doesn't "know" about previous revisions?

Is there a recommended strategy or procedure if someone just want to change one or two values and leave the rest as before?

TIA again,
Nils

Something like

select * from pm_projectsx where revision_id=:revision_id

where you'd use the latest or live revision from cr_items depending on which makes sense for your application.

Then you'd set the attributes for content::revision::new using that data.

Thank you, Dave, i will try it.
Wouldn't it make sense to have a "-latest" and "-live" boolean switch, which would define that content::revision::new should take the values from the live or latest revision whenever a value is not supplied?

Alternatively add an "-old_revision_id" switch?