{"id":32,"date":"2005-11-27T22:23:33","date_gmt":"2005-11-27T21:23:33","guid":{"rendered":"http:\/\/www.hlynes.com\/?p=32"},"modified":"2005-11-27T22:28:38","modified_gmt":"2005-11-27T21:28:38","slug":"a-day-with-catalyst","status":"publish","type":"post","link":"http:\/\/www.hlynes.com\/?p=32","title":{"rendered":"A Day With Catalyst"},"content":{"rendered":"<p>You may remember that after the <a href=\"http:\/\/blog.unixdaemon.net\/cgi-bin\/blosxom.pl\/2005\/11\/01\">Web Frameworks Evening<\/a> I rashly proposed that I would develop a <a href=\"http:\/\/www.hlynes.com\/2005\/11\/18\/web-frameworks-evening\/\">simple application with each of the frameworks mentioned<\/a>. Earlier in the week, as good as my word, I took <a href=\"http:\/\/catalyst.perl.org\/\">Catalyst<\/a> out for a spin.<\/p>\n<p>Out of the three frameworks Catalyst was the one I was most intrigued by. I&#8217;ve heard too many people in orange sunglasses rave about <a href=\"http:\/\/www.rubyonrails.com\/\">Rails<\/a> for me to get really excited about it. <a href=\"http:\/\/www.djangoproject.com\/\">Django<\/a> is written in my favourite language so it&#8217;s going to have to be especially horrid for me not to like it. The idea of a web framework that pulls in all the best tools of the Perl universe peaked my interest sufficiently that Catalyst was the first framework I decided to try.<\/p>\n<p>Now full diclosure time. I&#8217;m a bit of a Python bigot, but I thought, how many people learn ruby until they get wowed by Rails? If Catalyst is really good it could bring lots of new people into the Perl community. As a relative Perl newbie I make a good test of that idea. Would I find Catalyst sufficiently awesome that I would consider doing web development in something other than my native language?<\/p>\n<p><strong><code>perl -MCPAN -e 'install Bundle::Catalyst'<\/code><\/strong><\/p>\n<p>Three hours later after a series of cpan force installs I finally had Catalyst installed and not throwing empty Base Class errors. I know my way around CPAN I suspect the vast majority of people new to Perl don&#8217;t. You&#8217;ve just lost them.<\/p>\n<p>OK onto the <a href=\"http:\/\/search.cpan.org\/~agrundma\/Catalyst-5.57\/lib\/Catalyst\/Manual\/Tutorial.pod\">tutorial<\/a>. It&#8217;s pretty good. Writing views is really nice. Dispatching URLs to different functions is dead easy. The debugging output of the test server is massively helpful.  Right, onto templates. Hmmm&#8230;. OK you can call them explicitly by stashing the template name or it does a clever lookup on the name of the view or the function. Nice. I can see how you don&#8217;t need a lot of code to get real functionality out of this. It looks like a simple matter to knock up a function that passes an ID through and uses it for a database lookup. So I really need to move on in the tutorial and work out how to connect to my WordPress db and start grabbing some articles.<\/p>\n<p>Well the tutorial only mentions SQLite while I, and probably 99.9% of the world, am runnnig MySQL. Bit of googling should sort it. OK, no your Base Class is empty? Oh. More google. Aha I can connect now. The test server shows me a class has been created on the fly for each of my tables. The table names match what is in the database so I&#8217;m confident it&#8217;s actually talking to the DB. Right one line of code is all it should take to get data out. I can pass in a valid ID on the URL and use that to grab a record just like they show in the tutorial. But all I get back out is the ID. More google.<\/p>\n<p>Turns out you don&#8217;t get magic relationship mapping out of the box with MySQL and Catalyst::Model::CDBI. There probably is a way to do it but I can&#8217;t find any documentation on giving it a relationship map by hand. I&#8217;ve now spent nine hours trying to coax this whole thing into life so It&#8217;s time to cut my losses and move on.<\/p>\n<p>In short if you are not already a Perl hacker who knows his way aroung Class::DBI or Class::DBIx you may not find Catalyst to your taste. Which is a shame because it has moments of greatnes.<\/p>\n<p>Next time: Django<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You may remember that after the Web Frameworks Evening I rashly proposed that I would develop a simple application with each of the frameworks mentioned. Earlier in the week, as good as my word, I took Catalyst out for a spin. Out of the three frameworks Catalyst was the one I was most intrigued by. &hellip; <a href=\"http:\/\/www.hlynes.com\/?p=32\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">A Day With Catalyst<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-32","post","type-post","status-publish","format-standard","hentry","category-internet"],"_links":{"self":[{"href":"http:\/\/www.hlynes.com\/index.php?rest_route=\/wp\/v2\/posts\/32"}],"collection":[{"href":"http:\/\/www.hlynes.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.hlynes.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.hlynes.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.hlynes.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=32"}],"version-history":[{"count":0,"href":"http:\/\/www.hlynes.com\/index.php?rest_route=\/wp\/v2\/posts\/32\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.hlynes.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hlynes.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hlynes.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}