Forum OpenACS Development: sort_key is supposed to be a natural number... but it is getting passed a 1.00000...

Hi All

I have been debugging the wimpy point package, and when I try to add
slides to a newly created presentation I get the following message:

We had a problem processing your entry:

      sort_key is not a natural number, that is an integer greater
than or equal to 0.

Please back up using your browser, correct it, and resubmit your
entry.

Thank you.

Now I tried looking for something that might be causing this...  but I
found this piece of code in the .adp file

<td> <img src="pics/arrow.gif" alt="arrow" align=top> <font
size=-1><a
href="create-slide?pres_item_id=@pres_item_id@&sort_key=@slides.sort_key@">Insert</a></font>
</td>

My problem is that I do not understand where it is getting a value for
sort_key by running the command @slides.sort_key@

I have tried 'grep'ing for slides.sort_key but just cant seem to find
where this comes from.

Would anyone be able to help me out here?

Thanks
Jack P

Well it seems that the problem was actaully in the create file where sort_key was an element of the create table. It was givent type 'numeric'. I changed this to 'integer' and it seems to be working.

Any comments on whether this is the right thing to do?

thanks
Jack P

Look at the tcl code again to see how the sort key is generated.  In the case of the ecommerce packge, the sort keys are "numeric".  When inserting something between two existing keys, the midpoint of the two adjacent keys is used to calculate the new sort key.  If your package uses the same calculation, you need to keep the column as numeric.  The error looks like it came from ad_page_contract and it's most likely because the page contract specifies that sort_key is an integer.  Just change that to float and it should work.

FYI, slides.sort_key is probably from a multirow datasource.  "slides" is the datasource setup by db_multirow and "sort_key" is the column.  Check for db_multirow.