<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bluefeet &#187; Catalyst</title>
	<atom:link href="http://blog.bluefeet.net/tag/catalyst/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bluefeet.net</link>
	<description>Yet another Perl Hacker weblog</description>
	<lastBuildDate>Thu, 10 Jun 2010 15:22:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Upgrading to Catalyst 5.8</title>
		<link>http://blog.bluefeet.net/2009/07/upgrading-to-catalyst-5-8/</link>
		<comments>http://blog.bluefeet.net/2009/07/upgrading-to-catalyst-5-8/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 00:15:44 +0000</pubDate>
		<dc:creator>bluefeet</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Catalyst]]></category>
		<category><![CDATA[Moose]]></category>
		<category><![CDATA[Perl 5]]></category>

		<guid isPermaLink="false">http://blog.bluefeet.net/?p=157</guid>
		<description><![CDATA[Over the last few days at $work I&#8217;ve been upgrading Catalyst from 5.7 to 5.8.  This new version of catalyst, released in April, has been completely overhauled to use Moose for it&#8217;s OO system, among other enhancements and bug fixes.
I found that the Catalyst::Manual::CatalystAndMoose manual was a great starting point to using Moose with [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last few days at $work I&#8217;ve been upgrading Catalyst from 5.7 to 5.8.  This new version of catalyst, released in April, has been completely overhauled to use <a href="http://search.cpan.org/perldoc?Moose">Moose</a> for it&#8217;s OO system, among other enhancements and bug fixes.</p>
<p>I found that the <a href="http://search.cpan.org/perldoc?Catalyst::Manual::CatalystAndMoose">Catalyst::Manual::CatalystAndMoose</a> manual was a great starting point to using Moose with Catalyst.  Also, <a href="http://search.cpan.org/perldoc?Catalyst::Upgrading">Catalyst::Upgrading</a> has specific points to consider when upgrading to 5.8.  During the initial install of Catalyst 5.8 I was told that I had a few related modules installed, that while not Catalyst prerequisites, I should upgrade them as they were known to fail on the new Catalyst.  I was lucky that I caught this message, as cpan did not pause to wait for me to read it and went on its marry way building, testing, and installing Catalyst.</p>
<p>Once installed I went ahead and also upgraded some related modules we use such as <a href="http://search.cpan.org/perldoc?Catalyst::Plugin::Authentication">Catalyst::Plugin::Authentication</a>, <a href="http://search.cpan.org/perldoc?DBIx::Class">DBIx::Class</a>, <a href="http://search.cpan.org/perldoc?Catalyst::Plugin::Session">Catalyst::Plugin::Session</a>, <a href="http://search.cpan.org/perldoc?Catalyst::Authentication::Store::DBIx::Class">Catalyst::Authentication::Store::DBIx::Class</a>, etc.  This way I could test all these upgrades all at once instead of one at a time.</p>
<p>Next I modified all my custom plugins to use <a href="http://search.cpan.org/perldoc?MRO::Compat">MRO::Compat</a> instead of <a href="http://search.cpan.org/perldoc?Class::C3">Class::C3</a> per the documentation in <a href="http://search.cpan.org/perldoc?Class::C3::Adopt::NEXT">Class::C3::Adopt::NEXT</a>.  But, then I realized I might as well just rewrite all my plugins as <a href="http://search.cpan.org/perldoc?Moose::Role">Moose::Role</a>s as its pretty easy to convert a plugin to a role and you end up with much cleaner code.</p>
<p>I started Apache up and things mostly worked.  There were a few backwards incompatibilities that I wasn&#8217;t aware of, such as there were a few cases where developers had done this:</p>
<div class="codecolorer-container perl vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">sub</span> <a href="http://perldoc.perl.org/functions/index.html"><span style="color: #000066;">index</span></a> <span style="color: #339933;">:</span> Local <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span></div></div>
<p>Instead of:</p>
<div class="codecolorer-container perl vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">sub</span> <a href="http://perldoc.perl.org/functions/index.html"><span style="color: #000066;">index</span></a> <span style="color: #339933;">:</span> Private <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span></div></div>
<p>In our previous version of catalyst (5.7) using :Local, while not documented, worked just like :Private if the subroutine was named index.  In 5.8 only :Private will cause a handler named index to be the default handler if the URL resolves to the controller only.  This was an easy fix.  There were a couple other small issues, but nothing major.  I found and fixed <a href="https://rt.cpan.org//Ticket/Display.html?id=48084">a bug</a> in <a href="http://search.cpan.org/perldoc?Catalyst::Model::DBIC::Schema">Catalyst::Model::DBIC::Schema</a> and added the support for the compute() method to <a href="Catalyst::Plugin::Cache">Catalyst::Plugin::Cache</a>.  Both of these changes reduced the amount of changes I needed to make to my own code.</p>
<p>A couple hours in to it I was upgraded and everything was working.  Of course I spent the next few days upgrading/enhancing/rewriting Catalyst bits that could be done much more elegantly, and with less code, using Moose.</p>
<p>On a side note, during the upgrade I found this great quote in <a href="http://search.cpan.org/perldoc?Catalyst::Model::Adaptor">Catalyst::Model::Adaptor</a>:</p>
<blockquote><p>Catalyst is glue, not a way of life!</p></blockquote>
<p>Amen!  Most people, myself included, start out by writing all their business logic in their Controllers because that is what <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">MVC</a> told them to do.  Don&#8217;t do it!  Catalyst is meant to be a GLUE &#8211; most of your application should be written in a way that it doesn&#8217;t give a flying crap how, or by whom, it is used.  Put your business logic in modules that optionally expose themselves as Models (perhaps via <a href="http://search.cpan.org/perldoc?Catalyst::Model::Adaptor">Catalyst::Model::Adaptor</a>) or just by adding a use statement in your controller that then uses that module.  Your controllers should be little more than code to glue a data source with the view and provide some input validation.</p>
<p>I&#8217;ve been waiting a long time for this Moosification and its been a joy working with this new Catalyst.  Next up to bat will be the Moosification of <a href="http://search.cpan.org/perldoc?DBIx::Class">DBIx::Class</a>!  Think we&#8217;ll get it by Christmas?  :)</p>
<p>Don&#8217;t forget to buy the new <a href="http://www.shadowcat.co.uk/blog/matt-s-trout/the-definitive-guide-to-catalyst/">Catalyst Book</a>!  If purchasing from Amazon make sure you follow <a href="http://www.amazon.com/Definitive-Guide-Catalyst-Maintainable-Applications/dp/1430223650?&#038;camp=2486&#038;linkCode=wey&#038;tag=enligperlorga-21&#038;creative=8882">this link</a> to ensure that the <a href="http://www.enlightenedperl.org/">Enlightened Perl Organisation</a> gets a cut of the sale.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluefeet.net/2009/07/upgrading-to-catalyst-5-8/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
