[jifty-devel] Validating distinct fields

Edward Funnekotter efunneko at gmail.com
Mon Jun 5 07:25:03 EDT 2006

Sounds reasonable.  I was unaware that the validation function would be
called via AJAX automatically.  It doesn't seem to for me (firefox unless I specifically set 'ajax_validates' during
argument validation in my Action file, but I may have some configuration
problem preventing this.

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

More information about the jifty-devel mailing list