Forum OpenACS Development: Response to ad_form builder comments

Collapse
Posted by Don Baccus on
What are you doing for double-click protection if you're not pre-allocating the sequence ID?  Just trapping on other fields that are restricted to being unique?  What if there are no other columns other than the object_id that are so constrained?  Then without object id preallocation you get no double-click protection, right?

As Dave points you can use an on_submit clause if you decide not to use the built-in key allocation.  But using the built-in key management feature of ad_form shouldn't force you to write extra code - it's done for you automatically.  Among other things it makes it simple to use the same script for both editing existing data and adding new data in many cases.  And this is good because it means the form need only be declared once rather than in two separate scripts.  This should increase maintainability because you only need to make changes to the form in one place ...

-select_query and -select_query_name only work with the built-in key management stuff.  There may be some bugs regarding error checking if you're trying to use it without the built-in key management stuff.  I'll take a look at this.

If I were to rewrite the notes package to use ad_form I'd  use the built-in key management stuff.  The code would be much shorter, very easy to understand and would provide minimal ACS 3.x-style double-click protection, which the current notes package does not.  The current notes package will cheerfully double enter your note if you get bored and double-click the form (or triple click, quadruple click, etc).  This is "functionality" I would happily drop rather than attempt to replicate using ad_form.  While ACS 3.x-style double-click protection isn't perfect it's better than nothing, no?

Another thing ad_form does is to sign and verify the key it generates, giving some protection against bogus POST data.

At one point I had an on_request block implemented but didn't put it into the final ad_form that's in CVS because I didn't think it would be very useful and felt like I'd rather encourage folks to use the built-in key management feature for objects, at least, for consistency and simplicity.