<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Dev411 Blog: Category catalyst</title>
  <subtitle type="html">John Wang on Technology</subtitle>
  <id>tag:www.dev411.com,2005:Typo</id>
  <generator uri="http://www.typosphere.org" version="4.0">Typo</generator>
  <link href="http://www.dev411.com/blog/xml/atom/category/feed.xml" rel="self" type="application/atom+xml"/>
  <link href="http://www.dev411.com/blog/tag/catalyst" rel="alternate" type="text/html"/>
  <updated>2007-09-05T00:02:22-05:00</updated>
  <entry>
    <author>
      <name>John Wang</name>
    </author>
    <id>urn:uuid:fd57e1bd-e67a-47e8-96e7-2cffbf7b196a</id>
    <published>2007-09-04T23:38:00-05:00</published>
    <updated>2007-09-05T00:02:22-05:00</updated>
    <title type="html">Database Abstraction - code vs infrastructure</title>
    <link href="http://www.dev411.com/blog/2007/09/04/database-abstraction-code-vs-infrastructure" rel="alternate" type="text/html"/>
    <category term="postgresql" scheme="http://www.dev411.com/blog/tag/postgresql" label="postgresql"/>
    <category term="catalyst" scheme="http://www.dev411.com/blog/tag/catalyst" label="catalyst"/>
    <category term="activerecord" scheme="http://www.dev411.com/blog/tag/activerecord" label="activerecord"/>
    <category term="perl" scheme="http://www.dev411.com/blog/tag/perl" label="perl"/>
    <category term="mysql" scheme="http://www.dev411.com/blog/tag/mysql" label="mysql"/>
    <category term="typo" scheme="http://www.dev411.com/blog/tag/typo" label="typo"/>
    <category term="php" scheme="http://www.dev411.com/blog/tag/php" label="php"/>
    <summary type="html">&lt;p&gt;I've worked on a number of database-driven projects and no matter how much people want database abstraction, it was always difficult to code and maintain. I was recently reminded of this when I read this &lt;a href="http://www.drupal4hu.com/node/64" title="My stance on database abstraction"&gt;Drupal article on dropping PostgreSQL support&lt;/a&gt;. Not only can it be difficult to maintain support for multiple databases, but it may be difficult to find developers.&lt;/p&gt;

&lt;p&gt;One solution of modern programming is to move database abstraction from the code to the infrastructure using a ORM (Object-Relational Mapper) or Data Mapper. A ORM and Data Mapper abstracts the database for you so you no longer have to do tie db abstraction to each app. Not only does it let you code once for multiple databases it lets your users migrate their data from one database to another. This blog runs Typo which is based on Ruby on Rails and ActiveRecord. I've been contemplating migrating Typo from MySQL to PostgreSQL and I've been told that it would be as simple as exporting the data with YAML, updating the database.yml file and importing the data. I haven't gotten around to doing it yet but it is a powerful idea. ActiveRecord is a data mapper and isn't as flexible as a full blown ORM but it gets the job done for the most part. For a full-blown ORM, I think of Perl's DBIx::Class which provides a full OO interface to the RDBMS allowing you to code just once for multiple DBs without limiting you when you want to use some esoteric database-specific SQL. DBIx::Class is often used with the Catalyst Framework but is also used by itself.&lt;/p&gt;

&lt;p&gt;There are PHP frameworks out there like Symfony and Cake but do any of them have stand-alone ORMs? If so, could Drupal move to something like that and solve their maintainership problems once and for all? Drupal is part of the &lt;a href="http://gophp5.org"&gt;Go PHP5&lt;/a&gt; effort so there should be no issue using PHP 5 OO. Something to think about for the Drupal folks if a PHP ORM is available.&lt;/p&gt;</summary>
    <content type="html">&lt;p&gt;I've worked on a number of database-driven projects and no matter how much people want database abstraction, it was always difficult to code and maintain. I was recently reminded of this when I read this &lt;a href="http://www.drupal4hu.com/node/64" title="My stance on database abstraction"&gt;Drupal article on dropping PostgreSQL support&lt;/a&gt;. Not only can it be difficult to maintain support for multiple databases, but it may be difficult to find developers.&lt;/p&gt;

&lt;p&gt;One solution of modern programming is to move database abstraction from the code to the infrastructure using a ORM (Object-Relational Mapper) or Data Mapper. A ORM and Data Mapper abstracts the database for you so you no longer have to do tie db abstraction to each app. Not only does it let you code once for multiple databases it lets your users migrate their data from one database to another. This blog runs Typo which is based on Ruby on Rails and ActiveRecord. I've been contemplating migrating Typo from MySQL to PostgreSQL and I've been told that it would be as simple as exporting the data with YAML, updating the database.yml file and importing the data. I haven't gotten around to doing it yet but it is a powerful idea. ActiveRecord is a data mapper and isn't as flexible as a full blown ORM but it gets the job done for the most part. For a full-blown ORM, I think of Perl's DBIx::Class which provides a full OO interface to the RDBMS allowing you to code just once for multiple DBs without limiting you when you want to use some esoteric database-specific SQL. DBIx::Class is often used with the Catalyst Framework but is also used by itself.&lt;/p&gt;

&lt;p&gt;There are PHP frameworks out there like Symfony and Cake but do any of them have stand-alone ORMs? If so, could Drupal move to something like that and solve their maintainership problems once and for all? Drupal is part of the &lt;a href="http://gophp5.org"&gt;Go PHP5&lt;/a&gt; effort so there should be no issue using PHP 5 OO. Something to think about for the Drupal folks if a PHP ORM is available.&lt;/p&gt;

</content>
  </entry>
  <entry>
    <author>
      <name>John Wang</name>
    </author>
    <id>urn:uuid:a880c3da-4cab-4d9d-9c56-f8298f432a09</id>
    <published>2007-06-16T20:06:00-05:00</published>
    <updated>2007-07-07T15:43:14-05:00</updated>
    <title type="html">Single Sign-On (SSO) with and without subdomains</title>
    <link href="http://www.dev411.com/blog/2007/06/16/single-sign-on-sso-with-and-without-subdomains" rel="alternate" type="text/html"/>
    <category term="catalyst" scheme="http://www.dev411.com/blog/tag/catalyst" label="catalyst"/>
    <category term="authentication" scheme="http://www.dev411.com/blog/tag/authentication" label="authentication"/>
    <category term="singlesignon" scheme="http://www.dev411.com/blog/tag/singlesignon" label="singlesignon"/>
    <summary type="html">&lt;p&gt;If you are running a site without a subdomain, e.g. http://dev411.com and need to maintain cookie-based sessions across other server names with subdomains, e.g. blog.dev411.com and wiki.dev411.com, you will need to customize your session cookies.&lt;/p&gt;

&lt;p&gt;To have your session cookie be used across multiple subdomains, set a wildcard domain which starts with a dot followed by the base domain name, e.g. ".dev411.com", which will make it qualify for all subdomains of dev411.com. This, however, will not work for http://dev411.com where there is no subdomain.&lt;/p&gt;

&lt;p&gt;The have the same session used for http://dev411.com, set a second session cookie without domain. This way the domain-less cookie will be used for http://dev411.com and the wildcard domain cookie will be used for all subdomains.&lt;/p&gt;

&lt;p&gt;Catalyst 5.7007 will only set one cookie per cookie name, however, this solution works best when you can set both cookies with the same name but different cookie domains. I put together a &lt;a class="fix" href="http://www.dev411.com/catalyst/misc/Engine.pm.multi_cookie.patch"&gt;quick patch for &lt;span class="fix"&gt;Catalyst::Engine&lt;/span&gt;&lt;/a&gt; to allow multiple cookies when the cookie value is set to an arrayref.&lt;/p&gt;</summary>
    <content type="html">&lt;p&gt;If you are running a site without a subdomain, e.g. http://dev411.com and need to maintain cookie-based sessions across other server names with subdomains, e.g. blog.dev411.com and wiki.dev411.com, you will need to customize your session cookies.&lt;/p&gt;

&lt;p&gt;To have your session cookie be used across multiple subdomains, set a wildcard domain which starts with a dot followed by the base domain name, e.g. ".dev411.com", which will make it qualify for all subdomains of dev411.com. This, however, will not work for http://dev411.com where there is no subdomain.&lt;/p&gt;

&lt;p&gt;The have the same session used for http://dev411.com, set a second session cookie without domain. This way the domain-less cookie will be used for http://dev411.com and the wildcard domain cookie will be used for all subdomains.&lt;/p&gt;

&lt;p&gt;Catalyst 5.7007 will only set one cookie per cookie name, however, this solution works best when you can set both cookies with the same name but different cookie domains. I put together a &lt;a class="fix" href="http://www.dev411.com/catalyst/misc/Engine.pm.multi_cookie.patch"&gt;quick patch for &lt;span class="fix"&gt;Catalyst::Engine&lt;/span&gt;&lt;/a&gt; to allow multiple cookies when the cookie value is set to an arrayref.&lt;/p&gt;

</content>
  </entry>
  <entry>
    <author>
      <name>John Wang</name>
    </author>
    <id>urn:uuid:48685d3d-e5fa-4633-acac-99cd5e3e0b63</id>
    <published>2006-09-05T10:07:00-05:00</published>
    <updated>2007-07-28T18:30:44-05:00</updated>
    <title type="html">Perl 5 - Powering Web 2.0</title>
    <link href="http://www.dev411.com/blog/2006/09/05/perl-5-powering-web-2-0" rel="alternate" type="text/html"/>
    <category term="catalyst" scheme="http://www.dev411.com/blog/tag/catalyst" label="catalyst"/>
    <category term="perl" scheme="http://www.dev411.com/blog/tag/perl" label="perl"/>
    <summary type="html">&lt;p&gt;Whenever popular Perl sites are discussed, a number of large websites are mentioned with the usual suspects being Amazon, IMDB, LiveJournal, Slashdot and others. While this is a good list, what often doesn't get mentioned is the new Web 2.0 sites that Perl 5 is powering. Perl 5 web frameworks (such as &lt;a href="http://www.catalystframework.org"&gt;Catalyst&lt;/a&gt; and &lt;a href="http://www.jifty.org"&gt;Jifty&lt;/a&gt;), OO models (&lt;a href="http://search.cpan.org/dist/Moose/lib/Moose.pm"&gt;Moose&lt;/a&gt;) and other techniques (&lt;a href="http://par.perl.org"&gt;PAR&lt;/a&gt;) dramatically improve Perl for web development and large-scale projects making many complaints about the language irrelevant. These, when combined with CPAN, continue to make Perl 5 a very attractive language for new web apps.&lt;/p&gt;

&lt;p&gt;Examples of Perl-powered Web 2.0 sites include del.icio.us, (which uses the &lt;a href="http://www.masonhq.com"&gt;Mason&lt;/a&gt; templating system / mini-framework), EditGrid (an AJAX-enhanced online spreadsheet running on the Catalyst framework) and Vox (a multi-user blogging site by Six Apart, maker of LiveJournal, MovableType and TypePad). Other sites include HiveMinder, IUseThis, and MighTyV. Of these six sites, four are running on the Catalyst framework. HiveMinder is built on the Jifty framework. Yahoo is even interested in developers with Perl/Catalyst skills along with C and Java  for this &lt;a href="http://www.dev411.com/images/articles/200609/web20perl_yahoojob.png"&gt;Senior Software Engineering position&lt;/a&gt; (screenshot from &lt;a href="http://jobs.perl.org"&gt;jobs.perl.org&lt;/a&gt;). Screenshots and links of active sites are provided below.&lt;/p&gt;

&lt;div style="text-align:center"&gt;

&lt;table class="web20perl"&gt;&lt;tr&gt;&lt;td&gt;
&lt;a href="http://del.icio.us/"&gt;&lt;img class="w2p_image" alt="del.icio.us" src="http://www.dev411.com/images/articles/200609/web20perl_delicious_thumb.png" /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td class="web20perl"&gt;
&lt;strong&gt;del.icio.us&lt;/strong&gt;&lt;br /&gt;
Description: Social Bookmarking&lt;br /&gt;
Perl Framework: Mason
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;table class="web20perl"&gt;&lt;tr&gt;&lt;td&gt;
&lt;a href="http://www.editgrid.com/"&gt;&lt;img class="w2p_image" alt="editgrid" src="http://www.dev411.com/images/articles/200609/web20perl_editgrid_thumb.png" /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td class="web20perl"&gt;
&lt;strong&gt;EditGrid&lt;/strong&gt;&lt;br /&gt;
Description: Online Spreadsheets&lt;br /&gt;
Perl Framework: Catalyst
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;/div&gt;
</summary>
    <content type="html">&lt;p&gt;Whenever popular Perl sites are discussed, a number of large websites are mentioned with the usual suspects being Amazon, IMDB, LiveJournal, Slashdot and others. While this is a good list, what often doesn't get mentioned is the new Web 2.0 sites that Perl 5 is powering. Perl 5 web frameworks (such as &lt;a href="http://www.catalystframework.org"&gt;Catalyst&lt;/a&gt; and &lt;a href="http://www.jifty.org"&gt;Jifty&lt;/a&gt;), OO models (&lt;a href="http://search.cpan.org/dist/Moose/lib/Moose.pm"&gt;Moose&lt;/a&gt;) and other techniques (&lt;a href="http://par.perl.org"&gt;PAR&lt;/a&gt;) dramatically improve Perl for web development and large-scale projects making many complaints about the language irrelevant. These, when combined with CPAN, continue to make Perl 5 a very attractive language for new web apps.&lt;/p&gt;

&lt;p&gt;Examples of Perl-powered Web 2.0 sites include del.icio.us, (which uses the &lt;a href="http://www.masonhq.com"&gt;Mason&lt;/a&gt; templating system / mini-framework), EditGrid (an AJAX-enhanced online spreadsheet running on the Catalyst framework) and Vox (a multi-user blogging site by Six Apart, maker of LiveJournal, MovableType and TypePad). Other sites include HiveMinder, IUseThis, and MighTyV. Of these six sites, four are running on the Catalyst framework. HiveMinder is built on the Jifty framework. Yahoo is even interested in developers with Perl/Catalyst skills along with C and Java  for this &lt;a href="http://www.dev411.com/images/articles/200609/web20perl_yahoojob.png"&gt;Senior Software Engineering position&lt;/a&gt; (screenshot from &lt;a href="http://jobs.perl.org"&gt;jobs.perl.org&lt;/a&gt;). Screenshots and links of active sites are provided below.&lt;/p&gt;

&lt;div style="text-align:center"&gt;

&lt;table class="web20perl"&gt;&lt;tr&gt;&lt;td&gt;
&lt;a href="http://del.icio.us/"&gt;&lt;img class="w2p_image" alt="del.icio.us" src="http://www.dev411.com/images/articles/200609/web20perl_delicious_thumb.png" /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td class="web20perl"&gt;
&lt;strong&gt;del.icio.us&lt;/strong&gt;&lt;br /&gt;
Description: Social Bookmarking&lt;br /&gt;
Perl Framework: Mason
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;table class="web20perl"&gt;&lt;tr&gt;&lt;td&gt;
&lt;a href="http://www.editgrid.com/"&gt;&lt;img class="w2p_image" alt="editgrid" src="http://www.dev411.com/images/articles/200609/web20perl_editgrid_thumb.png" /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td class="web20perl"&gt;
&lt;strong&gt;EditGrid&lt;/strong&gt;&lt;br /&gt;
Description: Online Spreadsheets&lt;br /&gt;
Perl Framework: Catalyst
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;/div&gt;


&lt;div style="text-align:center"&gt;

&lt;table class="web20perl"&gt;&lt;tr&gt;&lt;td&gt;
&lt;a href="http://www.hiveminder.com/"&gt;&lt;img class="w2p_image" alt="hiveminder" src="http://www.dev411.com/images/articles/200609/web20perl_hiveminder_thumb.png" /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td class="web20perl"&gt;
&lt;strong&gt;HiveMinder&lt;/strong&gt;&lt;br /&gt;
Description: To Do Lists&lt;br /&gt;
Perl Framework: Jifty
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;table class="web20perl"&gt;&lt;tr&gt;&lt;td&gt;
&lt;a href="http://osx.iusethis.com/"&gt;&lt;img class="w2p_image" alt="iusethis" src="http://www.dev411.com/images/articles/200609/web20perl_iusethis_thumb.png" /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td class="web20perl"&gt;
&lt;strong&gt;IUseThis&lt;/strong&gt;&lt;br /&gt;
Description: App Lists&lt;br /&gt;
Perl Framework: Catalyst
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;table class="web20perl"&gt;&lt;tr&gt;&lt;td&gt;
&lt;a href="http://www.mightyv.com/day/"&gt;&lt;img class="w2p_image" alt="mightyv" src="http://www.dev411.com/images/articles/200609/web20perl_mightyv_thumb.png" /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td class="web20perl"&gt;
&lt;strong&gt;MighTyV&lt;/strong&gt;&lt;br /&gt;
Description: TV/Radio Listings&lt;br /&gt;
Perl Framework: Catalyst
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;table class="web20perl"&gt;&lt;tr&gt;&lt;td&gt;
&lt;a href="http://www.vox.com/"&gt;&lt;img class="w2p_image" alt="vox" src="http://www.dev411.com/images/articles/200609/web20perl_vox_thumb.png" /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td class="web20perl"&gt;
&lt;strong&gt;Vox&lt;/strong&gt;&lt;br /&gt;
Description: Blogging site by Six Apart&lt;br /&gt;
Perl Framework: Catalyst
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;/div&gt;

&lt;p&gt;These sites show that Perl 5 is alive and well as a language of choice for Web 2.0. Although Perl 5 is over 10 years old, the combination of new frameworks and techniques, combined with CPAN's 10,000+ modules, continue to make Perl an attractive choice. The key is to use make sure you are familiar with modern Perl programming techniques.&lt;/p&gt;.</content>
  </entry>
  <entry>
    <author>
      <name>John Wang</name>
    </author>
    <id>urn:uuid:e5e74674-1af8-4440-998c-a6b5b78d791d</id>
    <published>2006-08-03T10:28:00-05:00</published>
    <updated>2007-06-16T12:30:23-05:00</updated>
    <title type="html">Planet Catalyst</title>
    <link href="http://www.dev411.com/blog/2006/08/03/planet-catalyst" rel="alternate" type="text/html"/>
    <category term="catalyst" scheme="http://www.dev411.com/blog/tag/catalyst" label="catalyst"/>
    <category term="plagger" scheme="http://www.dev411.com/blog/tag/plagger" label="plagger"/>
    <summary type="html">&lt;p&gt;I just set up Planet Catalyst at &lt;a href="http://planet.catalystframework.org" title="Planet Catalyst"&gt;http://planet.catalystframework.org&lt;/a&gt; to aggregate blogs about the &lt;a href="http://www.catalystframework.org/"&gt;Catalyst MVC framework&lt;/a&gt;. It is also linked from the main Catalyst homepage and &lt;a href="http://planet.perl.org"&gt;Planet Perl&lt;/a&gt; so you can reach it from there. The planet is focused on articles related to Catalyst and friends which means it filters articles on catalyst, dbic, dbix(::|-)?class or html(::|-)?widget, h::w or handel (case insensitive). Let me know if there are any other topics of interest that should be included.&lt;/p&gt;

&lt;p&gt;Planet Catalyst is powered by &lt;a href="http://plagger.org/"&gt;Plagger&lt;/a&gt;, a Perl-based RSS/Atom feed aggregator. Thanks to Tatsuhiko Miyagawa for writing Plagger and answering my questions on the &lt;span class="fix"&gt;#plagger&lt;/span&gt; FreeNode IRC channel. It was very easy to add filtering on keywords by specifying a rule in the config file.&lt;/p&gt;

&lt;p&gt;If you have questions or would like a blog added, send email to the &lt;a href="http://lists.rawmode.org/mailman/listinfo/catalyst-dev"&gt;catalyst-dev mailing list&lt;/a&gt;, comment on this article or ask on &lt;span class="fix"&gt;#catalyst&lt;/span&gt; / &lt;span class="fix"&gt;#catalyst-dev&lt;/span&gt; perl.org IRC channels.&lt;/p&gt;</summary>
    <content type="html">&lt;p&gt;I just set up Planet Catalyst at &lt;a href="http://planet.catalystframework.org" title="Planet Catalyst"&gt;http://planet.catalystframework.org&lt;/a&gt; to aggregate blogs about the &lt;a href="http://www.catalystframework.org/"&gt;Catalyst MVC framework&lt;/a&gt;. It is also linked from the main Catalyst homepage and &lt;a href="http://planet.perl.org"&gt;Planet Perl&lt;/a&gt; so you can reach it from there. The planet is focused on articles related to Catalyst and friends which means it filters articles on catalyst, dbic, dbix(::|-)?class or html(::|-)?widget, h::w or handel (case insensitive). Let me know if there are any other topics of interest that should be included.&lt;/p&gt;

&lt;p&gt;Planet Catalyst is powered by &lt;a href="http://plagger.org/"&gt;Plagger&lt;/a&gt;, a Perl-based RSS/Atom feed aggregator. Thanks to Tatsuhiko Miyagawa for writing Plagger and answering my questions on the &lt;span class="fix"&gt;#plagger&lt;/span&gt; FreeNode IRC channel. It was very easy to add filtering on keywords by specifying a rule in the config file.&lt;/p&gt;

&lt;p&gt;If you have questions or would like a blog added, send email to the &lt;a href="http://lists.rawmode.org/mailman/listinfo/catalyst-dev"&gt;catalyst-dev mailing list&lt;/a&gt;, comment on this article or ask on &lt;span class="fix"&gt;#catalyst&lt;/span&gt; / &lt;span class="fix"&gt;#catalyst-dev&lt;/span&gt; perl.org IRC channels.&lt;/p&gt;

</content>
  </entry>
  <entry>
    <author>
      <name>John Wang</name>
    </author>
    <id>urn:uuid:885f059fcc2a7604158abbca1b8b8be6</id>
    <published>2006-07-25T10:49:00-05:00</published>
    <updated>2007-06-16T12:30:23-05:00</updated>
    <title type="html">Catalyst - Customizing the view to stop IE from caching JSON</title>
    <link href="http://www.dev411.com/blog/2006/07/25/catalyst-customizing-the-view-stop-ie-from-caching-json" rel="alternate" type="text/html"/>
    <category term="json" scheme="http://www.dev411.com/blog/tag/json" label="json"/>
    <category term="catalyst" scheme="http://www.dev411.com/blog/tag/catalyst" label="catalyst"/>
    <category term="ie" scheme="http://www.dev411.com/blog/tag/ie" label="ie"/>
    <category term="ajax" scheme="http://www.dev411.com/blog/tag/ajax" label="ajax"/>
    <summary type="html">&lt;p&gt;Often times you'll want to customize your response specific to the View being used, e.g. setting extra headers. This can be done directly in your View class by creating a &lt;span class="fix"&gt;process&lt;/span&gt; method. All View base classes have a process method defined in &lt;span class="fix"&gt;Catalyst::View&lt;/span&gt; that gets called at rendering time. By adding a &lt;span class="fix"&gt;process&lt;/span&gt; method in your subclass and redispatching to the parent you can do some preliminary processing.&lt;/p&gt;</summary>
    <content type="html">&lt;p&gt;Often times you'll want to customize your response specific to the View being used, e.g. setting extra headers. This can be done directly in your View class by creating a &lt;span class="fix"&gt;process&lt;/span&gt; method. All View base classes have a process method defined in &lt;span class="fix"&gt;Catalyst::View&lt;/span&gt; that gets called at rendering time. By adding a &lt;span class="fix"&gt;process&lt;/span&gt; method in your subclass and redispatching to the parent you can do some preliminary processing.&lt;/p&gt;

&lt;p&gt;One use is preventing IE from caching JSON responses by setting the Cache-Control and Pragma HTTP response headers. You can do this in the 
application's JSON view as follows:&lt;/p&gt;

&lt;pre&gt;package MyApp::View::JSON;
use strict; use warnings;
use base qw/Catalyst::View::JSON/;

sub process {
  my $self = shift;
  my $c = $_[0];
  $c-&gt;res-&gt;header( 'Cache-Control' =&gt;
    'no-store, no-cache, must-revalidate,'.
    'post-check=0, pre-check=0, max-age=0'
  );
  $c-&gt;res-&gt;header( 'Pragma' =&gt; 'no-cache' );
  $c-&gt;res-&gt;header( 'Expires' =&gt; 'Thu, 01 Jan 1970 00:00:00 GMT' );
  $self-&gt;NEXT::process(@_);
}

1;&lt;/pre&gt;

&lt;p&gt;Your &lt;span class="fix"&gt;process&lt;/span&gt; method will get called, set it's response headers and then use &lt;a href="http://search.cpan.org/~dconway/NEXT-0.60/lib/NEXT.pm" class="fix"&gt;NEXT&lt;/a&gt; to call C::V::JSON's &lt;span class="fix"&gt;process&lt;/span&gt; method.&lt;/p&gt;</content>
  </entry>
  <entry>
    <author>
      <name>John Wang</name>
    </author>
    <id>urn:uuid:310f8f2393192a4bf6885b036d510d30</id>
    <published>2006-07-24T20:40:00-05:00</published>
    <updated>2007-06-16T12:30:23-05:00</updated>
    <title type="html">JSON XSS exploit: don't use text/html</title>
    <link href="http://www.dev411.com/blog/2006/07/24/json-xss-exploit-dont-use-text-html" rel="alternate" type="text/html"/>
    <category term="json" scheme="http://www.dev411.com/blog/tag/json" label="json"/>
    <category term="catalyst" scheme="http://www.dev411.com/blog/tag/catalyst" label="catalyst"/>
    <category term="xss" scheme="http://www.dev411.com/blog/tag/xss" label="xss"/>
    <category term="security" scheme="http://www.dev411.com/blog/tag/security" label="security"/>
    <category term="dojo" scheme="http://www.dev411.com/blog/tag/dojo" label="dojo"/>
    <category term="ajax" scheme="http://www.dev411.com/blog/tag/ajax" label="ajax"/>
    <summary type="html">&lt;p&gt;&lt;a href="http://jibbering.com/blog/?p=514"&gt;Jim Ley reports&lt;/a&gt; on the &lt;a href="http://ha.ckers.org/blog/20060704/cross-site-scripting-vulnerability-in-google/"&gt;Google JSON XSS exploit&lt;/a&gt; with example code and screen shots of stealing information from the AdSense site. The moral of the story is don't use &lt;span class="fix"&gt;text/html&lt;/span&gt; for the MIME type when returning JSON, use &lt;span class="fix"&gt;application/json&lt;/span&gt; which is an &lt;a href="http://www.rfc-editor.org/rfc/rfc4627.txt"&gt;IETF standard (RFC 4627)&lt;/a&gt; now. Most browsers should handle &lt;span class="fix"&gt;application/json&lt;/span&gt; fine, however Opera may have problems and you may want to use &lt;span class="fix"&gt;application/x-javascript&lt;/span&gt; for that. Something to remember even if your AJAX code/library doesn't care about the MIME type returned by the server, e.g. Dojo.&lt;/p&gt;

&lt;p&gt;If you are using Catalyst and Catalyst::View::JSON, your JSON response will automatically be set to &lt;span class="fix"&gt;application/json&lt;/span&gt; for all user agents except Opera (which gets &lt;span class="fix"&gt;application/x-javascript&lt;/span&gt;) so you're already safe(r).&lt;/p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;a href="http://jibbering.com/blog/?p=514"&gt;Jim Ley reports&lt;/a&gt; on the &lt;a href="http://ha.ckers.org/blog/20060704/cross-site-scripting-vulnerability-in-google/"&gt;Google JSON XSS exploit&lt;/a&gt; with example code and screen shots of stealing information from the AdSense site. The moral of the story is don't use &lt;span class="fix"&gt;text/html&lt;/span&gt; for the MIME type when returning JSON, use &lt;span class="fix"&gt;application/json&lt;/span&gt; which is an &lt;a href="http://www.rfc-editor.org/rfc/rfc4627.txt"&gt;IETF standard (RFC 4627)&lt;/a&gt; now. Most browsers should handle &lt;span class="fix"&gt;application/json&lt;/span&gt; fine, however Opera may have problems and you may want to use &lt;span class="fix"&gt;application/x-javascript&lt;/span&gt; for that. Something to remember even if your AJAX code/library doesn't care about the MIME type returned by the server, e.g. Dojo.&lt;/p&gt;

&lt;p&gt;If you are using Catalyst and Catalyst::View::JSON, your JSON response will automatically be set to &lt;span class="fix"&gt;application/json&lt;/span&gt; for all user agents except Opera (which gets &lt;span class="fix"&gt;application/x-javascript&lt;/span&gt;) so you're already safe(r).&lt;/p&gt;

</content>
  </entry>
  <entry>
    <author>
      <name>John Wang</name>
    </author>
    <id>urn:uuid:57b4add3580c4de20c6bb9f96bd74e83</id>
    <published>2006-07-18T23:05:00-05:00</published>
    <updated>2007-06-16T12:30:23-05:00</updated>
    <title type="html">Catalyst and image libraries</title>
    <link href="http://www.dev411.com/blog/2006/07/18/catalyst-and-image-libraries" rel="alternate" type="text/html"/>
    <category term="imagemagick" scheme="http://www.dev411.com/blog/tag/imagemagick" label="imagemagick"/>
    <category term="catalyst" scheme="http://www.dev411.com/blog/tag/catalyst" label="catalyst"/>
    <summary type="html">&lt;p&gt;I just migrated my Catalyst app to use &lt;a href="http://www.boutell.com/gd/"&gt;GD&lt;/a&gt; instead of &lt;a href="http://www.imagemagick.org"&gt;ImageMagick&lt;/a&gt; based on some reported compatibility issues.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chris Laco reported &lt;a href="http://lists.rawmode.org/pipermail/catalyst/2006-March/006166.html"&gt;Apache2/mod_perl2 would core dump with ImageMagick (on FreeBSD)&lt;/a&gt;. He moved to FastCGI+ImageMagick first and is now using FastCGI+&lt;a href="http://imager.perl.org"&gt;Imager&lt;/a&gt;. ImageMagick has been reported to work with Mason+Apache1.x+mod_perl1.3.&lt;/li&gt;
&lt;li&gt;Andreas Marienborg reported on &lt;span class="fix"&gt;#catalyst&lt;/span&gt; IRC that Imager doesn't work with Catalyst+&lt;a href="http://par.perl.org"&gt;PAR&lt;/a&gt; and has moved to GD.&lt;/li&gt;
&lt;li&gt;Someone on &lt;span class="fix"&gt;#rubyonrails&lt;/span&gt; IRC mentioned having problems with RMagick and was looking to migrate to ruby-gd&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Wanting the best of all worlds, I moved to GD which also has a smaller memory footprint than ImageMagick. I ended up writing my own wrapper for Lincoln Stein's GD module using the Image::Magick API (drop-in replacement for a very limited set of functionality) though something like &lt;a href="http://search.cpan.org/~lgoddard/Image-Thumbnail-0.62/lib/Image/Thumbnail.pm"&gt;Image::Thumbnail&lt;/a&gt;, which provides a uniform interface to GD, ImageMagick and Imager, is probably better for general use.&lt;/p&gt;

&lt;p&gt;Thanks to Chris and Andreas for their reporting issues. Hopefully I'll be all set with GD.&lt;/p&gt;</summary>
    <content type="html">&lt;p&gt;I just migrated my Catalyst app to use &lt;a href="http://www.boutell.com/gd/"&gt;GD&lt;/a&gt; instead of &lt;a href="http://www.imagemagick.org"&gt;ImageMagick&lt;/a&gt; based on some reported compatibility issues.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chris Laco reported &lt;a href="http://lists.rawmode.org/pipermail/catalyst/2006-March/006166.html"&gt;Apache2/mod_perl2 would core dump with ImageMagick (on FreeBSD)&lt;/a&gt;. He moved to FastCGI+ImageMagick first and is now using FastCGI+&lt;a href="http://imager.perl.org"&gt;Imager&lt;/a&gt;. ImageMagick has been reported to work with Mason+Apache1.x+mod_perl1.3.&lt;/li&gt;
&lt;li&gt;Andreas Marienborg reported on &lt;span class="fix"&gt;#catalyst&lt;/span&gt; IRC that Imager doesn't work with Catalyst+&lt;a href="http://par.perl.org"&gt;PAR&lt;/a&gt; and has moved to GD.&lt;/li&gt;
&lt;li&gt;Someone on &lt;span class="fix"&gt;#rubyonrails&lt;/span&gt; IRC mentioned having problems with RMagick and was looking to migrate to ruby-gd&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Wanting the best of all worlds, I moved to GD which also has a smaller memory footprint than ImageMagick. I ended up writing my own wrapper for Lincoln Stein's GD module using the Image::Magick API (drop-in replacement for a very limited set of functionality) though something like &lt;a href="http://search.cpan.org/~lgoddard/Image-Thumbnail-0.62/lib/Image/Thumbnail.pm"&gt;Image::Thumbnail&lt;/a&gt;, which provides a uniform interface to GD, ImageMagick and Imager, is probably better for general use.&lt;/p&gt;

&lt;p&gt;Thanks to Chris and Andreas for their reporting issues. Hopefully I'll be all set with GD.&lt;/p&gt;

</content>
  </entry>
  <entry>
    <author>
      <name>John Wang</name>
    </author>
    <id>urn:uuid:3fa3a81839c96b0100c617195211eeeb</id>
    <published>2006-07-08T21:36:00-05:00</published>
    <updated>2007-06-16T12:30:22-05:00</updated>
    <title type="html">Catalyst 5.7000 released</title>
    <link href="http://www.dev411.com/blog/2006/07/08/catalyst-5-7000" rel="alternate" type="text/html"/>
    <category term="catalyst" scheme="http://www.dev411.com/blog/tag/catalyst" label="catalyst"/>
    <summary type="html">&lt;p&gt;A new major version of the &lt;a href="http://www.catalystframework.org"&gt;Catalyst framework&lt;/a&gt; has just been released. Read about it &lt;a href="http://digg.com/programming/New_major_release_of_the_Catalyst_MVC_framework"&gt;on Digg&lt;/a&gt;; here are the latest results I've seen:&lt;/p&gt;

&lt;div style="text-align:center"&gt;&lt;a href="http://digg.com/programming/New_major_release_of_the_Catalyst_MVC_framework"&gt;&lt;img src="/images/articles/200607/digg_catalyst570_sm.png" style="border:0" alt="Catalyst 5.700 Digg status" /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;It actually got to &lt;a href="/images/articles/200607/digg_catalyst570_fs.png"&gt;91 diggs at the top of the Digg homepage&lt;/a&gt; before a new article came along (I took screen shots in KDE too but the layout wasn't as nice as XP). From Jezmo's Digg comment, I learned that &lt;a href="http://www.somethingawful.com/"&gt;SomethingAwful&lt;/a&gt; (6th largest forum on the Internet) is &lt;a href="http://www.teambarry.com/?p=27"&gt;using Catalyst to build Titan&lt;/a&gt;, a schema-compatible vBulletin replacement. Catalyst is also used by &lt;a href="http://www.dresdner-ball-street.de"&gt;Dresdner Bank&lt;/a&gt;, &lt;a href="http://osx.iusethis.com"&gt;IUseThis&lt;/a&gt; and &lt;a href="http://www.editgrid.com"&gt;EditGrid&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://marcusramberg.livejournal.com/27223.html"&gt;Marcus has an announcement on his blog&lt;/a&gt; and the &lt;a href="/catalyst/Catalyst-5.7000_Changes"&gt;change log&lt;/a&gt; is available, but I'll summarize the changes here:&lt;/p&gt;

&lt;strong&gt;New Features&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;"ActionClass templates" which allow you to make extensible actions. The first of which is &lt;a href="http://search.cpan.org/~mramberg/Catalyst-Action-RenderView-0.04/lib/Catalyst/Action/RenderView.pm" class="fix"&gt;Catalyst::Action::RenderView&lt;/a&gt;, a more flexible replacement for the &lt;span class="fix"&gt;DefaultEnd&lt;/span&gt; plugin. Read more about this in &lt;a href="http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7000/lib/Catalyst/Manual/Actions.pod" class="fix"&gt;Catalyst::Manual::Actions&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;"Chained actions" which allow you to have parent and child actions on a uri. For example in a uri like &lt;span class="fix"&gt;/page/43/revision/23/edit&lt;/span&gt; you could have one action handle &lt;span class="fix"&gt;/page/43&lt;/span&gt; and another handle &lt;span class="fix"&gt;revision/23/edit&lt;/span&gt; with captures for 43, 23 and edit.&lt;/li&gt;
&lt;/ul&gt;
&lt;strong&gt;Enhancements&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;Major documentation improvements including the &lt;a href="http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7000/lib/Catalyst/Manual/Tutorial.pod"&gt;Tutorial&lt;/a&gt; and &lt;a href="http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7000/lib/Catalyst/Manual/Intro.pod"&gt;Introduction&lt;/a&gt; parts of the Catalyst manual, reference API documentation and the &lt;a href="http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7000/lib/Catalyst/Manual/Cookbook.pod"&gt;Cookbook&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;More concise log info and new colors for the debug screen.&lt;/li&gt;
&lt;li&gt;Switch from &lt;span class="fix"&gt;Module::Pluggable::Fast&lt;/span&gt; to &lt;span class="fix"&gt;Module::Pluggable&lt;/span&gt; for more fine grain control over &lt;span class="fix"&gt;setup_components&lt;/span&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;strong&gt;New Packaging&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;span class="fix"&gt;Catalyst&lt;/span&gt; distribution has been split into &lt;span class="fix"&gt;Catalyst::Runtime&lt;/span&gt; and &lt;span class="fix"&gt;Catalyst::Devel&lt;/span&gt;. &lt;span class="fix"&gt;Runtime&lt;/span&gt; contains the minimal parts for deployment while &lt;span class="fix"&gt;Devel &lt;/span&gt; includes helpers and tools. Thankfully &lt;span class="fix"&gt;install Catalyst&lt;/span&gt; in CPAN will install &lt;span class="fix"&gt;Catalyst::Runtime&lt;/span&gt; and there's no need to change the &lt;span class="fix"&gt;use Catalyst;&lt;/span&gt; lines in your App Classes.&lt;/li&gt;
&lt;/ul&gt;

&lt;strong&gt;Upgrade Gotchas&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Catalyst::Engine::Apache FIRSTKEY error: I just upgraded from &lt;span class="fix"&gt;Catalyst&lt;/span&gt; 5.6902 and &lt;span class="fix"&gt;Catalyst::Engine::Apache&lt;/span&gt; 1.06. I didn't have a problem running 5.6902 and 1.06 but others had the generic problem below and previously upgraded to 1.07. The problem only appeared with 5.7000 and 1.06 for me. In any event, make sure you're running &lt;span class="fix"&gt;Catalyst::Engine::Apache&lt;/span&gt; 1.07.&lt;/p&gt;

&lt;pre&gt;[error] Caught exception in engine "Can't locate
  object method "FIRSTKEY" via package "APR::Table" at
  /path/to/site_perl/5.8.7/Catalyst/Engine/Apache.pm 
  line 65."&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;</summary>
    <content type="html">&lt;p&gt;A new major version of the &lt;a href="http://www.catalystframework.org"&gt;Catalyst framework&lt;/a&gt; has just been released. Read about it &lt;a href="http://digg.com/programming/New_major_release_of_the_Catalyst_MVC_framework"&gt;on Digg&lt;/a&gt;; here are the latest results I've seen:&lt;/p&gt;

&lt;div style="text-align:center"&gt;&lt;a href="http://digg.com/programming/New_major_release_of_the_Catalyst_MVC_framework"&gt;&lt;img src="/images/articles/200607/digg_catalyst570_sm.png" style="border:0" alt="Catalyst 5.700 Digg status" /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;It actually got to &lt;a href="/images/articles/200607/digg_catalyst570_fs.png"&gt;91 diggs at the top of the Digg homepage&lt;/a&gt; before a new article came along (I took screen shots in KDE too but the layout wasn't as nice as XP). From Jezmo's Digg comment, I learned that &lt;a href="http://www.somethingawful.com/"&gt;SomethingAwful&lt;/a&gt; (6th largest forum on the Internet) is &lt;a href="http://www.teambarry.com/?p=27"&gt;using Catalyst to build Titan&lt;/a&gt;, a schema-compatible vBulletin replacement. Catalyst is also used by &lt;a href="http://www.dresdner-ball-street.de"&gt;Dresdner Bank&lt;/a&gt;, &lt;a href="http://osx.iusethis.com"&gt;IUseThis&lt;/a&gt; and &lt;a href="http://www.editgrid.com"&gt;EditGrid&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://marcusramberg.livejournal.com/27223.html"&gt;Marcus has an announcement on his blog&lt;/a&gt; and the &lt;a href="/catalyst/Catalyst-5.7000_Changes"&gt;change log&lt;/a&gt; is available, but I'll summarize the changes here:&lt;/p&gt;

&lt;strong&gt;New Features&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;"ActionClass templates" which allow you to make extensible actions. The first of which is &lt;a href="http://search.cpan.org/~mramberg/Catalyst-Action-RenderView-0.04/lib/Catalyst/Action/RenderView.pm" class="fix"&gt;Catalyst::Action::RenderView&lt;/a&gt;, a more flexible replacement for the &lt;span class="fix"&gt;DefaultEnd&lt;/span&gt; plugin. Read more about this in &lt;a href="http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7000/lib/Catalyst/Manual/Actions.pod" class="fix"&gt;Catalyst::Manual::Actions&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;"Chained actions" which allow you to have parent and child actions on a uri. For example in a uri like &lt;span class="fix"&gt;/page/43/revision/23/edit&lt;/span&gt; you could have one action handle &lt;span class="fix"&gt;/page/43&lt;/span&gt; and another handle &lt;span class="fix"&gt;revision/23/edit&lt;/span&gt; with captures for 43, 23 and edit.&lt;/li&gt;
&lt;/ul&gt;
&lt;strong&gt;Enhancements&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;Major documentation improvements including the &lt;a href="http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7000/lib/Catalyst/Manual/Tutorial.pod"&gt;Tutorial&lt;/a&gt; and &lt;a href="http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7000/lib/Catalyst/Manual/Intro.pod"&gt;Introduction&lt;/a&gt; parts of the Catalyst manual, reference API documentation and the &lt;a href="http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7000/lib/Catalyst/Manual/Cookbook.pod"&gt;Cookbook&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;More concise log info and new colors for the debug screen.&lt;/li&gt;
&lt;li&gt;Switch from &lt;span class="fix"&gt;Module::Pluggable::Fast&lt;/span&gt; to &lt;span class="fix"&gt;Module::Pluggable&lt;/span&gt; for more fine grain control over &lt;span class="fix"&gt;setup_components&lt;/span&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;strong&gt;New Packaging&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;span class="fix"&gt;Catalyst&lt;/span&gt; distribution has been split into &lt;span class="fix"&gt;Catalyst::Runtime&lt;/span&gt; and &lt;span class="fix"&gt;Catalyst::Devel&lt;/span&gt;. &lt;span class="fix"&gt;Runtime&lt;/span&gt; contains the minimal parts for deployment while &lt;span class="fix"&gt;Devel &lt;/span&gt; includes helpers and tools. Thankfully &lt;span class="fix"&gt;install Catalyst&lt;/span&gt; in CPAN will install &lt;span class="fix"&gt;Catalyst::Runtime&lt;/span&gt; and there's no need to change the &lt;span class="fix"&gt;use Catalyst;&lt;/span&gt; lines in your App Classes.&lt;/li&gt;
&lt;/ul&gt;

&lt;strong&gt;Upgrade Gotchas&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Catalyst::Engine::Apache FIRSTKEY error: I just upgraded from &lt;span class="fix"&gt;Catalyst&lt;/span&gt; 5.6902 and &lt;span class="fix"&gt;Catalyst::Engine::Apache&lt;/span&gt; 1.06. I didn't have a problem running 5.6902 and 1.06 but others had the generic problem below and previously upgraded to 1.07. The problem only appeared with 5.7000 and 1.06 for me. In any event, make sure you're running &lt;span class="fix"&gt;Catalyst::Engine::Apache&lt;/span&gt; 1.07.&lt;/p&gt;

&lt;pre&gt;[error] Caught exception in engine "Can't locate
  object method "FIRSTKEY" via package "APR::Table" at
  /path/to/site_perl/5.8.7/Catalyst/Engine/Apache.pm 
  line 65."&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

</content>
  </entry>
  <entry>
    <author>
      <name>John Wang</name>
    </author>
    <id>urn:uuid:f1b5c3269c8309f002c755448ed81e4c</id>
    <published>2006-06-14T01:06:00-05:00</published>
    <updated>2007-06-16T12:30:22-05:00</updated>
    <title type="html">Localization / Internationalization with Catalyst</title>
    <link href="http://www.dev411.com/blog/2006/06/14/localization-internationalization-with-catalyst" rel="alternate" type="text/html"/>
    <category term="catalyst" scheme="http://www.dev411.com/blog/tag/catalyst" label="catalyst"/>
    <category term="perl" scheme="http://www.dev411.com/blog/tag/perl" label="perl"/>
    <category term="localization" scheme="http://www.dev411.com/blog/tag/localization" label="localization"/>
    <summary type="html">&lt;p&gt;I played with Catalyst::Plugin::I18N today to test returning text according to the user's language. This is called internationalization (I18N) or localization (L10N). I prefer the term localization when customizing output for users for this (and internationalization for storing multi-lingual data in the backend) but the definition is subject to debate and both are used. It seems there are two stages to L10N: locale detection and the localization.&lt;/p&gt;

&lt;p&gt;C::P::I18N can do dection based on an explicit setting:&lt;/p&gt;

&lt;pre&gt;$c-&gt;languages( ['de'] );&lt;/pre&gt;

&lt;p&gt;or automatic browser detection based on the browser's &lt;span class="fix"&gt;HTTP_ACCEPT_LANGUAGE&lt;/span&gt;. C::P::I18N does the localization portion using string substitution. To set this up put your string definitions in the your mo/po or Maketext classes and then localize in the View, for example using TT:&lt;/p&gt;

&lt;pre&gt;[% c.loc('Hello World') %]&lt;/pre&gt;

&lt;p&gt;Also make sure to set the Vary header to assist with caching:&lt;/p&gt;

&lt;pre&gt;# Covers one or more Vary headers
$c-&gt;res-&gt;headers-&gt;push_header(
    Vary =&gt; 'Accept-Language'
);

# If you only have one Vary header
$c-&gt;res-&gt;header( Vary =&gt; 'Accept-Language' );&lt;/pre&gt;

&lt;p&gt;The Vary header should theoretically handle proxy caching though these servers are typically out of your control and cannot be guaranteed to recognize and process the header.&lt;/p&gt;

&lt;p&gt;The other popular detection option seems to be to put the locale in the URI, either in the domain name (e.g. http://www.mysite.cn) or in the path / query string, as opposed to reading a HTTP request parameter.&lt;/p&gt;

&lt;p&gt;Cal Henderson's Building Scalable Websites O'Reilly book talks about Localization and mentions three methods:&lt;/p&gt;

&lt;ol&gt;&lt;li&gt;string substitution&lt;/li&gt;&lt;li&gt;multiple template sets&lt;/li&gt;&lt;li&gt;multiple frontends&lt;/li&gt;&lt;/ol&gt;

&lt;p&gt;Cal mentions all three methods are hard and doesn't give an outright recommendation. He does, however, lists problems with string substitution and multple template sets but not multiple frontends so perhaps he's implicitly recommending the latter. He doesn't talk about detection methods. At first I was very excited to get Cal's book because I thought he would make outright recommendations. I'm starting to realize it's more of a primer and you have to tease out the best option.&lt;/p&gt;

&lt;p&gt;Do you L10N or I18N? If so, how do you do it?&lt;/p&gt;</summary>
    <content type="html">&lt;p&gt;I played with Catalyst::Plugin::I18N today to test returning text according to the user's language. This is called internationalization (I18N) or localization (L10N). I prefer the term localization when customizing output for users for this (and internationalization for storing multi-lingual data in the backend) but the definition is subject to debate and both are used. It seems there are two stages to L10N: locale detection and the localization.&lt;/p&gt;

&lt;p&gt;C::P::I18N can do dection based on an explicit setting:&lt;/p&gt;

&lt;pre&gt;$c-&gt;languages( ['de'] );&lt;/pre&gt;

&lt;p&gt;or automatic browser detection based on the browser's &lt;span class="fix"&gt;HTTP_ACCEPT_LANGUAGE&lt;/span&gt;. C::P::I18N does the localization portion using string substitution. To set this up put your string definitions in the your mo/po or Maketext classes and then localize in the View, for example using TT:&lt;/p&gt;

&lt;pre&gt;[% c.loc('Hello World') %]&lt;/pre&gt;

&lt;p&gt;Also make sure to set the Vary header to assist with caching:&lt;/p&gt;

&lt;pre&gt;# Covers one or more Vary headers
$c-&gt;res-&gt;headers-&gt;push_header(
    Vary =&gt; 'Accept-Language'
);

# If you only have one Vary header
$c-&gt;res-&gt;header( Vary =&gt; 'Accept-Language' );&lt;/pre&gt;

&lt;p&gt;The Vary header should theoretically handle proxy caching though these servers are typically out of your control and cannot be guaranteed to recognize and process the header.&lt;/p&gt;

&lt;p&gt;The other popular detection option seems to be to put the locale in the URI, either in the domain name (e.g. http://www.mysite.cn) or in the path / query string, as opposed to reading a HTTP request parameter.&lt;/p&gt;

&lt;p&gt;Cal Henderson's Building Scalable Websites O'Reilly book talks about Localization and mentions three methods:&lt;/p&gt;

&lt;ol&gt;&lt;li&gt;string substitution&lt;/li&gt;&lt;li&gt;multiple template sets&lt;/li&gt;&lt;li&gt;multiple frontends&lt;/li&gt;&lt;/ol&gt;

&lt;p&gt;Cal mentions all three methods are hard and doesn't give an outright recommendation. He does, however, lists problems with string substitution and multple template sets but not multiple frontends so perhaps he's implicitly recommending the latter. He doesn't talk about detection methods. At first I was very excited to get Cal's book because I thought he would make outright recommendations. I'm starting to realize it's more of a primer and you have to tease out the best option.&lt;/p&gt;

&lt;p&gt;Do you L10N or I18N? If so, how do you do it?&lt;/p&gt;

</content>
  </entry>
  <entry>
    <author>
      <name>John Wang</name>
    </author>
    <id>urn:uuid:77762545b1dda44d93f114f89f64dfb0</id>
    <published>2006-06-05T20:52:00-05:00</published>
    <updated>2007-06-16T12:30:22-05:00</updated>
    <title type="html">HTML::Prototype - AJAX Without JavaScript</title>
    <link href="http://www.dev411.com/blog/2006/06/05/html-prototype-ajax-without-javascript" rel="alternate" type="text/html"/>
    <category term="catalyst" scheme="http://www.dev411.com/blog/tag/catalyst" label="catalyst"/>
    <category term="perl" scheme="http://www.dev411.com/blog/tag/perl" label="perl"/>
    <category term="templatetoolkit" scheme="http://www.dev411.com/blog/tag/templatetoolkit" label="templatetoolkit"/>
    <category term="ajax" scheme="http://www.dev411.com/blog/tag/ajax" label="ajax"/>
    <category term="scriptaculous" scheme="http://www.dev411.com/blog/tag/scriptaculous" label="scriptaculous"/>
    <category term="prototype" scheme="http://www.dev411.com/blog/tag/prototype" label="prototype"/>
    <summary type="html">&lt;p&gt;&lt;a href="http://search.cpan.org/~esskar/HTML-Prototype-1.45/lib/HTML/Prototype.pm"&gt;HTML::Prototype&lt;/a&gt; is by far the most painless way to get started with AJAX that I've found. Simply put, you do not need to know or write any JavaScript! HTML::Prototype is a Perl module on CPAN that wraps the prototype AJAX library and Script.aculo.us effects library with Perl helper methods so you don't need to write a single line of JavaScript to get some great effects. There are also a number of modules that wrap HTML::Prototype for integration with &lt;a href="http://search.cpan.org/~sri/Catalyst-Plugin-Prototype-1.32/lib/Catalyst/Plugin/Prototype.pm"&gt;Catalyst&lt;/a&gt;, &lt;a href="http://search.cpan.org/~ceeshek/CGI-Application-Plugin-HTMLPrototype-0.20/lib/CGI/Application/Plugin/HTMLPrototype.pm"&gt;CGI::Application&lt;/a&gt;, &lt;a href="http://search.cpan.org/~bauerb/Template-Plugin-HTML-Prototype-0.01/lib/Template/Plugin/HTML/Prototype.pm"&gt;Template Toolkit&lt;/a&gt; and others.&lt;/p&gt;

&lt;p&gt;There are a number of convenient methods such as &lt;span class="fix"&gt;link_to_remote()&lt;/span&gt; and &lt;span class="fix"&gt;submit_to_remote()&lt;/span&gt; that create a link and form button to make an AJAX call and populate the innerHTML of a specified DOM element with the response body. Syntactic sugar to be sure as the JS generated by HTML::Prototype is very simple once you look at it, but the beauty is that you never have to.&lt;/p&gt;

&lt;p&gt;To truly appreciate HTML::Prototype you need to use some of Scriptaculous' more advanced widgets such as autocomplete. Sebastian Riedel put together a screencast using Catalyst that demonstrates how easy it is to use. Links to the screencast are available on the Catalyst wiki movies page:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dev.catalyst.perl.org/wiki/Movies"&gt;http://dev.catalyst.perl.org/wiki/Movies&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another great thing about having HTML::Prototype generate the JS syntax for you is that you can learn prototype syntax just by View Source. I picked up enough of prototype's JS syntax this way that I haven't looked at the docs yet.&lt;/p&gt;

&lt;p&gt;I've recently removed HTML::Prototype from a project in favor of using &lt;span class="fix"&gt;prototype.js&lt;/span&gt; and &lt;span class="fix"&gt;scriptaculous.js&lt;/span&gt; directly and I'm evaluating the Dojo Toolkit but HTML::Prototype let me get started with very effective, painless AJAX functionality. I used it with Catalyst::Plugin::Prototype and thought 'this is how frameworks make you productive.' Thanks to all the contributors.&lt;/p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;a href="http://search.cpan.org/~esskar/HTML-Prototype-1.45/lib/HTML/Prototype.pm"&gt;HTML::Prototype&lt;/a&gt; is by far the most painless way to get started with AJAX that I've found. Simply put, you do not need to know or write any JavaScript! HTML::Prototype is a Perl module on CPAN that wraps the prototype AJAX library and Script.aculo.us effects library with Perl helper methods so you don't need to write a single line of JavaScript to get some great effects. There are also a number of modules that wrap HTML::Prototype for integration with &lt;a href="http://search.cpan.org/~sri/Catalyst-Plugin-Prototype-1.32/lib/Catalyst/Plugin/Prototype.pm"&gt;Catalyst&lt;/a&gt;, &lt;a href="http://search.cpan.org/~ceeshek/CGI-Application-Plugin-HTMLPrototype-0.20/lib/CGI/Application/Plugin/HTMLPrototype.pm"&gt;CGI::Application&lt;/a&gt;, &lt;a href="http://search.cpan.org/~bauerb/Template-Plugin-HTML-Prototype-0.01/lib/Template/Plugin/HTML/Prototype.pm"&gt;Template Toolkit&lt;/a&gt; and others.&lt;/p&gt;

&lt;p&gt;There are a number of convenient methods such as &lt;span class="fix"&gt;link_to_remote()&lt;/span&gt; and &lt;span class="fix"&gt;submit_to_remote()&lt;/span&gt; that create a link and form button to make an AJAX call and populate the innerHTML of a specified DOM element with the response body. Syntactic sugar to be sure as the JS generated by HTML::Prototype is very simple once you look at it, but the beauty is that you never have to.&lt;/p&gt;

&lt;p&gt;To truly appreciate HTML::Prototype you need to use some of Scriptaculous' more advanced widgets such as autocomplete. Sebastian Riedel put together a screencast using Catalyst that demonstrates how easy it is to use. Links to the screencast are available on the Catalyst wiki movies page:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dev.catalyst.perl.org/wiki/Movies"&gt;http://dev.catalyst.perl.org/wiki/Movies&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another great thing about having HTML::Prototype generate the JS syntax for you is that you can learn prototype syntax just by View Source. I picked up enough of prototype's JS syntax this way that I haven't looked at the docs yet.&lt;/p&gt;

&lt;p&gt;I've recently removed HTML::Prototype from a project in favor of using &lt;span class="fix"&gt;prototype.js&lt;/span&gt; and &lt;span class="fix"&gt;scriptaculous.js&lt;/span&gt; directly and I'm evaluating the Dojo Toolkit but HTML::Prototype let me get started with very effective, painless AJAX functionality. I used it with Catalyst::Plugin::Prototype and thought 'this is how frameworks make you productive.' Thanks to all the contributors.&lt;/p&gt;

</content>
  </entry>
</feed>

