Sounds reasonable.&nbsp; I was unaware that the validation function would be called via AJAX automatically.&nbsp; 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.&nbsp; 
<br><br><br><div><span class="gmail_quote">On 6/4/06, <b class="gmail_sendername">Sean E. Millichamp</b> &lt;<a href="mailto:sean@enertronllc.com">sean@enertronllc.com</a>&gt; 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>&gt; I find for a number of models that I am using in my current project, I<br>&gt; am creating actions for adding records so that I can validate that<br>&gt; certain fields are not duplicated in the database rather than just
<br>&gt; using the Create&lt;Name&gt;.pm automatic action.&nbsp;&nbsp;I think that I could do<br>&gt; this my having a validation function specified in the record<br>&gt; definition within my model file, but is there a reason that we don't
<br>&gt; just use the 'is distinct' attribute to get the <a href="http://Action.pm">Action.pm</a> default<br>&gt; 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.&nbsp;&nbsp;That could result<br>in a lot of DB queries.&nbsp;&nbsp;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.&nbsp;&nbsp;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.&nbsp;&nbsp;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?&nbsp;&nbsp;I was pondering committing a
<br>patch exactly like yours, but at the Jifty::DBI layer.&nbsp;&nbsp;You wouldn't<br>have automatic AJAX checking, but I decided that I could live with<br>waiting for the user to click &quot;Submit&quot; and performing all of the 'is
<br>distinct' checks one time each.<br><br>As far as creating Create&lt;name&gt; 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.&nbsp;&nbsp;Then Jifty::Action::Record will automatically use
<br>that validator, saving you from having to create the Create&lt;name&gt;<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>