Sounds reasonable. I was unaware that the validation function would be called via AJAX automatically. It doesn't seem to for me (firefox <a href="http://1.5.0.4/jifty-head">1.5.0.4/jifty-head</a>) unless I specifically set 'ajax_validates' during argument validation in my Action file, but I may have some configuration problem preventing this.
<br><br><br><div><span class="gmail_quote">On 6/4/06, <b class="gmail_sendername">Sean E. Millichamp</b> <<a href="mailto:sean@enertronllc.com">sean@enertronllc.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Sun, 2006-06-04 at 20:53 -0400, Edward Funnekotter wrote:<br>> I find for a number of models that I am using in my current project, I<br>> am creating actions for adding records so that I can validate that<br>> certain fields are not duplicated in the database rather than just
<br>> using the Create<Name>.pm automatic action. I think that I could do<br>> this my having a validation function specified in the record<br>> definition within my model file, but is there a reason that we don't
<br>> just use the 'is distinct' attribute to get the <a href="http://Action.pm">Action.pm</a> default<br>> validator to do the checking always?<br><br>Hi Edward,<br><br>I was actually just starting to look at what it would take to implement
<br>'is distinct' at the Jifty::DBI layer in the last day or so.<br><br>After looking your patch over my biggest concern would be performance.<br>In an environment performing AJAX validations that function gets called<br>
every time the focus moves away from any form field. That could result<br>in a lot of DB queries. I believe that the caching functionality should<br>handle any positive hits but on a quick skim I don't see any negative<br>
hit caching functionality in either Jifty::DBI::Record::Cachable or<br>Memcached. That would mean that for the expected case (a non-existent<br>value was entered into the field) it would result in a DB query for each<br>
field marked with 'is distinct' each time focus leaves any AJAX<br>validated field. In a small application I don't suspect that would be<br>too noticeable, but with a large dataset or large number of users that<br>might become a noticeable lag.
<br><br>In my opinion, that particular check probably belongs in Jifty::DBI.<br>The notes in the docs say it is waiting for support from DBIx::DBSchema<br>- presumably to generate the needed SQL? I was pondering committing a
<br>patch exactly like yours, but at the Jifty::DBI layer. You wouldn't<br>have automatic AJAX checking, but I decided that I could live with<br>waiting for the user to click "Submit" and performing all of the 'is
<br>distinct' checks one time each.<br><br>As far as creating Create<name> actions just to put in the validator, I<br>believe you could probably do that check using the validator hook in<br>your Jifty::Model. Then Jifty::Action::Record will automatically use
<br>that validator, saving you from having to create the Create<name><br>action.<br><br>Sean<br><br>--<br> Sean E. Millichamp, Enertron LLC, 586-757-1200 x102<br><br><br>_______________________________________________
<br>jifty-devel mailing list<br><a href="mailto:jifty-devel@lists.jifty.org">jifty-devel@lists.jifty.org</a><br><a href="http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel">http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
</a><br></blockquote></div><br>