Forum OpenACS Development: Re: Code changes in MyFirstPackage

Collapse
Posted by Jim Lynch on
Heya Nils...

This will take a few messages to get everything explained...

First off... in your proc, you're grabbing the next object_id from the sequence... which is the same thing that happens when you pass "" for object_id to acs_object__new...

So you could do:

ad_proc -public mfp::note::add {
    -title:required
    -item_id
} {
    This proc adds a note.
} {
    if { ! [info exists item_id] } {
        set item_id ""
    }

    :
    :
}
and get a similar result (note also replacing "c eq 0" with "! c"; eq is a string compare, == is numeric)

More to come (about why even have the item_id come into the func if it's to be a new object) later :)

Collapse
Posted by Nils Lohse on
Heya Jim,

okay, i see, there exist better methods to deal with an empty item_id (see also Jun's Posting)...

... but the main point is, that the original tutorial source code says:

ad_proc -public mfp::note::add {
    -title:required
    -item_id:required
} {
    This proc adds a note.
} {  ...

I removed the :required-clause behind -item_id to match the tutorial description and get the code running.

That's why i'm wondering/asking... tutorial code shouldn't be needed to be fixed... 😉

Nils

Collapse
Posted by Jim Lynch on
(quote)tutorial code shouldn't be needed to be fixed...(/quote)

Yes, there is that...

BUT

you got the app working?

Collapse
Posted by Nils Lohse on
Hi Jim,

yes, i got the app working. So it's no problem for me, just irritating/confusing... 😉

But maybe other people won't be able to fix the code.

And i think, most people won't expect such "tasks" in a tutorial... 😉

Anyway, my intention just was to ask if i was right. (I belong to the people that don't expect... and so on <smile>)

Nils

Collapse
Posted by Jim Lynch on
Sometimes I think, "why not leave this bug in" so that the tutorial includes a small challenge...

Other times, I think it would be better if it were fixed.

If you read the bug report you'll see my {here's the point of passing in the item_id as received from the item_id key field of the form} comment, and you'll also see that I didn't put the type of posting right so you have to scroll to the right a lot to read it...

Anyway, the double-click thing is not unique to openacs, but not everyone gets that right. As an exercise, alter your app so that it passes the key from the form into the note__new call.