[jifty-devel] canonicalize_ ajax call not doing the right thing

Andrew Hanenkamp sterling at hanenkamp.com
Mon Jan 7 11:09:42 EST 2008


The two places to look for server-side management of these is Jifty::Action
and you can look through Jifty::Action::Record. Particularly the
_canonicalize_argument method of Jifty::Action. The work in
Jifty::Action::Record is primarily just some connective tissue to make
Jifty::Record canonicalizers become Jifty::Action canonicalizers.

The canonicalization code in JavaScript for the client-side can be found in
share/web/static/js/jifty.js. Here you can look for the validate method of
the Action object. Canonicalization takes place by scanning for XML nodes
named "canonicalizeaction", so searching for that should get you to the
client-side code that is most specific to what you're looking for.

You may also want to look at share/web/templates/__Jifty/webservices/xml if
you think there might be something wonky with the transport mechanism
between the action code on the server and the client-side code.

I hope that gets you started.


On 1/5/08, Peter Mottram <peter at sysnix.com> wrote:
> I'm seeing some weirdness when using canonicalize_ inside my model as
> there is a difference between how the ajax call handles things (badly) and
> how the final POST request handles things (correctly).
> Here's an extract of the relevant parts of my model:
> <code>
> package MyApp::Model::Product;
> use base qw(MyApp::Record);
> use Jifty::DBI::Schema;
> use MyApp::Record schema {
>    column partnumber =>
>      type is 'text',
>      label is 'Product Number',
>      max_length is 12,
>      is mandatory,
>      is distinct;
> }
> sub canonicalize_partnumber {
>      my $self = shift;
>      my $value = shift;
>      $value =~ s/[\s\W]+//g;
>      Jifty->log->info(qq(x${value}x));
>      return uc($value);
> }
> </code>
> And here is an extract from the log during a session in which I set the
> partnumber to ';s' (the semi-colon should be removed and then the string
> then uc'd):
> <log>
> INFO - GET request for /__jifty/validator.xml
> INFO - xx
> INFO - POST request for /product
> INFO - xsx
> INFO - xSx
> </log>
> So the ajax validator sees an empty value! If I enter somthing nice and
> simple like '45th e4' then the result via ajax is correct as it returns
> '45THE4'.
> Could someone please point me in the right direction as to where to start
> poking around in the Jifty code?
> Cheers
> PeteM
> _______________________________________________
> 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/20080107/9a1aa56c/attachment-0001.htm

More information about the jifty-devel mailing list