<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Catalyzed.org</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/" />
    <link rel="self" type="application/atom+xml" href="http://www.catalyzed.org/atom.xml" />
    <id>tag:www.catalyzed.org,2009-04-13://1</id>
    <updated>2010-06-24T17:32:00Z</updated>
    <subtitle>A Catalyst and Perl Blog</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.25</generator>

<entry>
    <title>YAPC::2010!</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2010/06/yapc2010-a-review.html" />
    <id>tag:www.catalyzed.org,2010://1.88</id>

    <published>2010-06-24T18:00:00Z</published>
    <updated>2010-06-24T17:32:00Z</updated>

    <summary>YAPC this year was great. I met a lot of people I only knew on the interwebs, went to some great talks, and got my ass heckled. I enjoyed every moment of it. Matt Trout gave a great ironman forfeit...</summary>
    <author>
        <name>Devin Austin</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=2</uri>
    </author>
    
        <category term="Catalyst" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="2010" label="2010" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="catalyst" label="catalyst" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="extending" label="extending" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="moose" label="moose" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="poe" label="poe" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="talks" label="talks" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="yapc" label="yapc" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<p>YAPC this year was great.</p>

<p>I met a lot of people I only knew on the interwebs, went to some great talks, and got my ass heckled.  I enjoyed every moment of it.</p>

<p>Matt Trout gave a great ironman forfeit talk, Stevan Little gave a great keynote on Tuesday, Nick Perez gave (6) great talks, 2 of which I was able to attend, Jesse Leuhrs showed me how to extend Moose like a boss, Chris Prather told me why MooseX::POE sucks and why I shouldn't use it, and I learned some Klingon from Paul Fenwick.  Jay Shirley talked about a sensible way to use templates to control your UI, keeping designers AND programmers happy, and Cory Watson talked about selling Moose to your bosses and managing your data verification stack with Data::Manager.</p>

<p>My talks went mostly okay.  Intro to Catalyst was a bit of a farce, but hey! We all learned something that day: Catalyst makes things get done faster.  Thumbit was fun to talk about, and I actually got a good deal of hacking done on the code to make it (almost) work.  Google Summer of Code will always be near and dear to my heart, my first talk, which is about my first dip into the magical waters of open source development.</p>

<p>I bid YAPC2010 a fond farewell, and shout outs to every one I met and everyone I got to hang out with after hours.</p>

<p>Until next year!</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Using Bread::Board to Create a Config API</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2010/06/using-breadboard-to-create-a-config-api.html" />
    <id>tag:www.catalyzed.org,2010://1.87</id>

    <published>2010-06-11T09:09:00Z</published>
    <updated>2010-06-11T20:51:35Z</updated>

    <summary>I&apos;ve finally been able to play with the massively fun toy that is Bread::Board. What is it, you say? Bread::Board is basically a way to wire application components up in a DRY, and efficient manner. This is extremely useful for...</summary>
    <author>
        <name>Devin Austin</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=2</uri>
    </author>
    
        <category term="Catalyst" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="board" label="board" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="bread" label="bread" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="config" label="config" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="services" label="services" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<p>I've finally been able to play with the massively fun toy that is Bread::Board.</p>

<p>What is it, you say?</p>

<p>Bread::Board is basically a way to wire application components up in a DRY, and efficient manner.  This is extremely useful for application configuration, and application setup (database handles/connection pooling, configuration file location, logger class setup, etc.).</p>

<p>The example I have put together involves the above, with a relatively sane method for setting up a configuration API so it's reusable and not a TOTAL pain in the ass.</p>

<p>Basically, I looked at <a href="http://github.com/perigrin/blawd">blawd</a> and stole the configuration bits and mangled them into something I could use.</p>

<p>Check it out (this comes from my minimal CMS <a href="http://github.com/dhoss/Deimos">Deimos</a>:</p>

<pre><code>package Deimos::ConfigContainer;
use Moose;
use namespace::autoclean;
use Bread::Board;
use Data::Dumper;
use Deimos::Schema; 
use Config::JFDI;
use Template;

has 'log_file_name' =&gt; (
  is      =&gt; 'ro',
  isa     =&gt; 'Str',
  default =&gt; "deimos.conf"
);

has 'config' =&gt; (
  is =&gt; 'ro',
  lazy_build =&gt; 1,
);

sub _build_config {
  my $self = shift;
  my $cfg = Config::JFDI-&gt;new( path =&gt; $something . $self-&gt;log_file_name );
  return $cfg-&gt;get;
}

sub build {
  my ($self, $service) = @_;
  my $cfg = $self-&gt;config;
  my $c = container Deimos =&gt; as {

    service 'site_title' =&gt; (
        block =&gt; sub {
            my $self = shift;
            return $self-&gt;config-&gt;{'site_title'};
        },
        dependencies =&gt; [ depends_on('config') ],
    );

    service 'log_file' =&gt; $self-&gt;log_file_name;

    service 'config' =&gt; $cfg;

    service 'schema' =&gt; (
        lifecycle =&gt; "Singleton",
        block =&gt; sub {
            warn "config: " . Dumper $cfg;
           return Deimos::Schema-&gt;connect(
               @{ $cfg-&gt;{'Database'}-&gt;{'connect_info'} },
            );
          }
    );

    service 'templates' =&gt; ( 
        block =&gt; sub {
            return Template-&gt;new($cfg-&gt;{'templates'});
        }
    );

    service 'application' =&gt; (
        class        =&gt; 'Deimos',
        dependencies =&gt; {
            schema     =&gt; depends_on('schema'),
            config     =&gt; depends_on('config'),
            site_title =&gt; depends_on('site_title'),
        }
    );
};

    return $c-&gt;fetch($service)-&gt;get;
}

 __PACKAGE__-&gt;meta-&gt;make_immutable;
1;
</code></pre>

<p>Basically, this allows you to either use your configcontainer, or, like I plan to, create a role, and apply it as needed and do $self->config->fetch('service_name');</p>

<p>This makes life MUCH much easier on the configuration front.</p>

<p>I hope this helps someone out there like it helped me when I finally got it figured out.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Catalyst::Controller::LeakTracker Tutorial</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2010/05/catalystcontrollerleaktracker-tutorial.html" />
    <id>tag:www.catalyzed.org,2010://1.86</id>

    <published>2010-05-27T00:00:00Z</published>
    <updated>2010-05-26T22:32:32Z</updated>

    <summary>Why use LeakTracker? You have a Catalyst application that is consuming more and more memory over time. You would like to find out what classes are involved and where you may have cyclic references. Why not try out nothingmuch&apos;s handy...</summary>
    <author>
        <name>mateu</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=9</uri>
    </author>
    
        <category term="Catalyst" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="catalystleaktrackerperl" label="catalyst leaktracker perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<h1>Why use LeakTracker?</h1>

<p>You have a Catalyst application that is consuming more and more memory over time. You would like to find out what classes are involved and where you may have cyclic references.  Why not try out <em>nothingmuch's</em> handy dandy <b>Catalyst::Controller::LeakTracker</b>.</p>

<p><a href="http://suryahunter.com/wiki/hunter/perl_ironman/leaktracker_tutorial">Full Article</a></p>]]>
        
    </content>
</entry>

<entry>
    <title>Transactions with DBIC</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2010/05/transactions-with-dbic.html" />
    <id>tag:www.catalyzed.org,2010://1.85</id>

    <published>2010-05-10T05:59:00Z</published>
    <updated>2010-05-09T18:55:58Z</updated>

    <summary>Overview Transactions are an important feature of many database management systems. Transactions allow one to make changes to a data store in a reliable way that can gracefully handle failure. In short you are guaranteed that the changes take place...</summary>
    <author>
        <name>mateu</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=9</uri>
    </author>
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<h1>Overview</h1>

<p>Transactions are an important feature of many database management systems.  Transactions allow one to make changes to a data store in a reliable way that can gracefully handle failure. In short you are guaranteed that the changes take place in their entirety or not at all.  In addition, transactions provide isolation for concurrent transactions to avoid data from being changed out from under you. This petit article demonstrates transactions using <span class="caps">DBI</span>x::Class, a kickass <span class="caps">ORM </span>for Perl.</p>

<p><a href="http://wisdom.webhop.org/wiki/hunter/database/orm/transactions_with_dbic">Full Article</a></p>]]>
        
    </content>
</entry>

<entry>
    <title>Installing DBD::Pg and DBD::mysql on Mac OSX (Snow Leopard)</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2010/05/installing-dbdpg-and-dbdmysql-on-mac-osx-snow-leopard.html" />
    <id>tag:www.catalyzed.org,2010://1.76</id>

    <published>2010-05-07T20:26:00Z</published>
    <updated>2010-05-07T20:31:58Z</updated>

    <summary>I went through a lot initially trying to get perl to be able to interface to mysql and postgres on Mac OSX. My steps weren&apos;t optimal, and I wouldn&apos;t recommend them for anyone. However, after purchasing my Mac Book Pro,...</summary>
    <author>
        <name>Devin Austin</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=2</uri>
    </author>
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="dbdmyql" label="dbd::myql" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="dbdpg" label="dbd::pg" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mac" label="mac" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mysql" label="mysql" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="osx" label="osx" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="pg" label="pg" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="postgres" label="postgres" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<p>I went through a lot initially trying to get perl to be able to interface to mysql and postgres on Mac OSX.  My steps weren't optimal, and I wouldn't recommend them for anyone.</p>

<p>However,  after purchasing my Mac Book Pro, I had to go through the process again, but this time, it was much more refined.  So in essence, it boils down to this:</p>

<ol>
<li>Make sure you have your flavor of mysql or postgresql installed AND PAY ATTENTION TO WHETHER IT SHOULD BE A 32 BIT BUILD OR A 64 BIT BUILD.  If you are on a modern mac, chances are you're going to be using a 64 bit build of either of these.</li>
<li>wget the latest DBD::Pg or DBD::mysql driver from CPAN.  You're going to have to manually build these with the libs and flags your mysql was built with.  The easiest way to obtain these flags via mysql_config --cflags and --libs (respective config for pg too).  Then, run perl Makfile.PL with --cflags and --libs set with the appropriate settings</li>
<li>Make sure mysql/pg are actually running!  Your tests will fail otherwise.</li>
</ol>

<p>This is brief, hurried, and probably not nearly as comprehensive as others. But, it should give you a relatively intuitive overview of how to get it going on your shiny mac.</p>

<p>Please let me know if I've left anything out!</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Announcing Bracket</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2010/04/announcuing.html" />
    <id>tag:www.catalyzed.org,2010://1.82</id>

    <published>2010-04-12T16:37:50Z</published>
    <updated>2010-04-13T17:50:57Z</updated>

    <summary>Bracket is a web application that manages a group of players and their picks in the national college basketball tournament. It was written to provide an open source bracket system for the tourney that is fast, simple and ad free....</summary>
    <author>
        <name>mateu</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=9</uri>
    </author>
    
        <category term="Catalyst" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<p>Bracket is a web application that manages a group of players and their picks in the national college basketball tournament.  It was written to provide an open source bracket system for the tourney that is fast, simple and ad free.</p>

<p>(update: sorry for the post-march madness post, this is all dhoss's fault)</p>]]>
        <![CDATA[<h1> Download</h1>

<p>The source is available at:</p>

<p>http://github.com/mateu/Bracket</p>

<p>Download it via:</p>



<pre>
git clone git://github.com/mateu/Bracket.git
</pre>



<h1>Install</h1>

<h2>Dependencies</h2>

<p>Get the <span class="caps">CPAN </span>dependencies like so:</p>



<pre>
cd Bracket
perl Makefile.PL
make test
</pre>



<h1>Create admin account and Deploy the Database</h1>

<p>For the sake of simplicity we'll assume a <span class="caps">SQL</span>ite database deployment<sup class="footnote"><a href="http://www.catalyzed.org/2010/04/announcuing.html#fn1">1</a></sup>.</p>



<pre>
script/deploy_bracket.pl
</pre>



<p>You will be prompted to create an admin account<sup class="footnote"><a href="http://www.catalyzed.org/2010/04/announcuing.html#fn2">2</a></sup>.</p>

<h1>Start the Application</h1>

<p>Once the database has been deployed and an admin account created, on can start up an instance of the application and test it out.  Start the test instance like so:</p>



<pre>
script/bracket_server.pl
</pre>



<p>This will create the Bracket web application on http://localhost:3000/.  Since it's a Catalyst one has a variety of ways to run the instance: fastcgi, mod_perl, psgi etc.</p>

<h1>Usage Notes</h1>

<h2>Accounts</h2>

<p>Bracket provides login management such as password change and reset.</p>

<h2>Scoring</h2>

<p>Any admin account has the ability to edit the Perfect Player&#0153; bracket and compute scores.</p>

<h2>Views</h2>

<p>Players can view each others brackets while in progress, but only admins can edit another player's bracket.</p>


<h1>Footnotes</h1>

<p class="footnote" id="fn1"><sup>1</sup> This saves us from having to edit bracket.conf with a database dsn, user and pass.  In addition we don't have to create the database in advance like we would with PostgreSQL or MySQL.</p>

<p class="footnote" id="fn2"><sup>2</sup> An account with admin role is necessary to mark the Perfect Player&#0153; bracket<br />
which is used to computes scores.  Computing scores is another admin only role.</p>]]>
    </content>
</entry>

<entry>
    <title>MooseX::App::Cmd and your Command Line Apps</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2010/04/moosexappcmd-and-your-command-line-apps.html" />
    <id>tag:www.catalyzed.org,2010://1.84</id>

    <published>2010-04-06T17:50:04Z</published>
    <updated>2010-04-12T22:15:51Z</updated>

    <summary>MooseX::App::Cmd is a really handy little module to add robustness and decoupling to your command line applications. It allows you to treat each command as a separate class, keeping your code tidy, and pretty re-usable. Continue reading for an example...</summary>
    <author>
        <name>Devin Austin</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=2</uri>
    </author>
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="app" label="app" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="command" label="command" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="line" label="line" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="modular" label="modular" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="moose" label="moose" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mvc" label="mvc" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<p><a href="http://search.cpan.org/~nuffin/MooseX-App-Cmd-0.06/lib/MooseX/App/Cmd.pm">MooseX::App::Cmd</a> is a really handy little module to add robustness and decoupling to your command line applications.  It allows you to treat each command as a separate class, keeping your code tidy, and pretty re-usable.</p>

<p>Continue reading for an example of what I recently used it for....</p>
]]>
        <![CDATA[<p>This is the main class:</p>

<pre><code>package App::MyApp;
use Moose;
use namespace::autoclean;
extends 'MooseX::App::Cmd';

1;
</code></pre>

<p>From here, you define your commands as such:</p>

<pre><code>package App::MyApp::Command::get;
use Moose;
use namespace::autoclean;
extends 'MooseX::App::Cmd::Command';

has bucket =&gt; (
    is            =&gt; 'rw',
    isa           =&gt; 'Str',
    traits        =&gt; ['Getopt'],
    cmd_aliases   =&gt; "b",
    documentation =&gt; "bucket name to look up",
    required      =&gt; 1,
    lazy          =&gt; 1,
    default       =&gt; sub { croak "bucket name required" },
 );

has object =&gt; (
    is            =&gt; 'rw',
    isa           =&gt; 'Str',
    traits        =&gt; ['Getopt'],
    cmd_aliases   =&gt; "o",
    documentation =&gt; "object to download",
    required      =&gt; 1,
    lazy          =&gt; 1,
    default       =&gt; sub { croak  "object name required" },
); 

sub execute {
    my ( $self, $opt, $args ) = @_;

    my $container =
    ## this would be something an inherited class might 
    ## provide, a database handle, etc.
      $self-&gt;object_thingy-&gt;container( name =&gt; $self-&gt;bucket );
    my $object = $container-&gt;object( name =&gt; $self-&gt;object );
    $object-&gt;get_filename( $self-&gt;object )
      or die "Couldn't retrieve object: $!";

}
1;
</code></pre>

<p>Finally, the initialization script:</p>

<pre><code>#!/usr/bin/env perl
use App::MyApp;
App::MyApp-&gt;run;
</code></pre>

<p>And it's invoked as such: </p>

<pre><code>myapp.pl get filename.txt
</code></pre>

<p>This makes your code much much more modular, allowing you to focus on keeping your business logic in one place and inheriting from it anywhere (much like different views in the MVC concept).</p>
]]>
    </content>
</entry>

<entry>
    <title>RFC: Weakly proxying Catalyst&apos;s context object</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2010/04/rfc-weakly-proxying-catalysts-context-object.html" />
    <id>tag:www.catalyzed.org,2010://1.83</id>

    <published>2010-04-01T21:38:32Z</published>
    <updated>2010-04-02T01:45:33Z</updated>

    <summary>Many of you will have run into this problem: You want to stash a callback in Catalyst that will build you the URL for an action. It&#8217;s supposed to be a callback, because you want to dynamically pass an ID...</summary>
    <author>
        <name>Robert &apos;phaylon&apos; Sedlacek</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=34</uri>
    </author>
    
        <category term="Catalyst" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="catalyst" label="Catalyst" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="sugar" label="sugar" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<p>Many of you will have run into this problem: You want to stash
a callback in <a href="http://www.catalystframework.org/">Catalyst</a> that will build you the URL for
an action. It&#8217;s supposed to be a callback, because you want to
dynamically pass an ID or other argument to the URL.</p>

<p>As nice as this sounds, you have to be careful so you don&#8217;t
create a circular reference. I&#8217;ll discuss the current best practice
for this problem below and will propose another kind of solution.</p>
]]>
        <![CDATA[<h2>How you should do it now</h2>

<p>Currently, the best practice is to use the 
<a href="http://search.cpan.org/dist/Catalyst-Runtime/lib/Catalyst/Component/ContextClosure.pm">ContextClosure</a> component trait. It will provide
your controller with a new method called <code>make_context_closure</code>.
To create a URL builder callback using <code>uri_for_action</code> (which I
hope you are using already) you&#8217;d do something like this:</p>

<pre><code>$ctx-&gt;stash(uri_for_post =&gt; $self-&gt;make_context_closure(sub {
    my ($ctx, $id) = @_;
    $ctx-&gt;uri_for_action('/post/view', [$id]);
}, $ctx));
</code></pre>

<p>This solves the problem nice and elegantly. You pass in your code
reference and original context and it returns a code reference
that weakly references the context object and will pass it into
your code reference everytime it&#8217;s called.</p>

<p>However, I find that rather wordy if I have a controller that uses
many callbacks. Also, one might forget to use <code>make_context_closure</code>
and simply pass in a closure or something else referencing the
context object by accident.</p>

<p>And besides, I&#8217;ve always been bugged by having code in the controller
that&#8217;s more utility than actual controller logic.</p>

<h2>How one might do it</h2>

<p>The core of the matter is that if you stash something that holds a
reference to the context object, you have a circular reference. In
the case of the code reference this is:</p>

<ol>
<li>The context object, which references &#8230;</li>
<li>the stash data structure, which references &#8230;</li>
<li>the code reference, which references &#8230;</li>
<li>the context object, &#8230;</li>
</ol>

<p>The obvious and common solution to this problem is introducing a weak
link in the chain. In the above example it is done by a second code
reference that only holds a weakened reference. This essentially means
the link exists between the items 2 and 3 on the above list. It would
look like this:</p>

<ol>
<li>The context object, which references &#8230;</li>
<li>the stash data structure, which references &#8230;</li>
<li>the generated callback wrapper, which <strong>weakly</strong> references &#8230;</li>
<li>the code reference, which references &#8230;</li>
<li>the context object, &#8230;</li>
</ol>

<p>I thought I&#8217;d take another route and insert the weak link between 3 and 4
instead. That is, directly between the referencing structure and the
context object.</p>

<p>This is done by wrapping the context object with a proxy that will hold
a weak reference to the original context, and will delegate all method 
calls to it. The chain would then look something like this:</p>

<ol>
<li>The context object, which references &#8230;</li>
<li>the stash data structure, which references &#8230;</li>
<li>the code reference, which references &#8230;</li>
<li>the proxy object, which <strong>weakly</strong> references &#8230;</li>
<li>the context object, &#8230;</li>
</ol>

<p>Of course, this proxy must only be passed into controller-space. But
that&#8217;s the only place where it is useful anyway.</p>

<h2>Code Examples</h2>

<p>Alright, enough with the boring theory. How would this look like in 
action? There are two distributions that I currently only have on GitHub.</p>

<p>One is <a href="http://github.com/phaylon/Object-WeakProxy">Object::WeakProxy</a>. This implements the basic proxy
object class that holds the weak reference and delegates all calls.</p>

<p>The other one is <a href="http://github.com/phaylon/Catalyst-TraitFor-Controller-WeakContext">Catalyst::TraitFor::Controller::WeakContext</a>.
This controller trait can be composed into any modern Catalyst controller.
It will modify the controller so that the context object that is passed
to your actions is already a weak proxy. A full example would look like
this:</p>

<pre><code>package MyApp::Controller::Foo;
use Moose;
BEGIN { 
    extends 'Catalyst::Controller';
    with    'Catalyst::TraitFor::Controller::WeakContext';
}

sub bar: Chained('/') Args(0) {
    my ($self, $ctx) = @_;

    $ctx-&gt;stash(uri_for_post =&gt; sub {
        $ctx-&gt;uri_for_action('/post/view', [shift]);
    });
}

1;
</code></pre>

<p>As you can see, since the <code>$ctx</code> variable holds no longer the context object,
but rather the proxy that weakly references it, you don&#8217;t need to pass the
code reference to a currying generator. It also feels a lot more intuitive to
me. And there&#8217;s also no chance of accidentally creating a circular reference
by stashing something referencing the context object.</p>

<p>The two above modules have tests and small documentation (how much can one
write about this?), but aren&#8217;t yet on CPAN. I&#8217;d like to hear people&#8217;s comments
before releasing it.</p>

<p>Also, I find it a bit odd that there isn&#8217;t such a component yet. Maybe I just
missed it. If so, please tell me!</p>
]]>
    </content>
</entry>

<entry>
    <title>An Introduction to FormHandler</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2010/03/an-introduction-to-formhandler.html" />
    <id>tag:www.catalyzed.org,2010://1.81</id>

    <published>2010-03-05T13:02:01Z</published>
    <updated>2010-03-05T07:26:47Z</updated>

    <summary>Abstract There is more than one way to handle forms in your Catalyst/DBIC application. This paper speaks to the HTML::FormHandler way. Let&apos;s start with a simple example of building a registration form to allow new users to register with your...</summary>
    <author>
        <name>mateu</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=9</uri>
    </author>
    
        <category term="Catalyst" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="catalyst" label="Catalyst" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="dbic" label="DBIC" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="htmlformhandler" label="HTML::FormHandler" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<h1>Abstract</h1>

<p>There is more than one way to handle forms in your Catalyst/DBIC application.  This paper speaks to the <span class="caps">HTML</span>::FormHandler way.  Let's start with a simple example of building a registration form to allow new users to register with your website application<sup class="footnote"><a href="http://www.catalyzed.org/2010/03/an-introduction-to-formhandler.html#fn1">1</a></sup>.  We will look at how to build a registration form object and use it in a Catalyst controller.  Furthermore, the form will integrate with a <span class="caps">DBIC </span>connected database to persist the registration information submitted via the form.</p>]]>
        <![CDATA[<h1>Build a Form Class</h1>

<p>We build a registration form class that uses the <span class="caps">DBIC </span>model like so:</p>



<pre>
package Bracket::Form::Register;

use HTML::FormHandler::Moose;
extends 'HTML::FormHandler::Model::DBIC';
with 'HTML::FormHandler::Render::Table';

has '+item_class' =&gt; ( default =&gt; 'Player' );

has_field 'first_name' =&gt; ( type =&gt; 'Text' );
has_field 'last_name'  =&gt; ( type =&gt; 'Text' );
has_field 'email'      =&gt; (
	type   =&gt; 'Email',
        required =&gt; 1,
	unique =&gt; 1,
);
has_field 'password'         =&gt; ( type =&gt; 'Password' );
has_field 'password_confirm' =&gt; ( type =&gt; 'PasswordConf' );
has_field 'submit' =&gt; ( type =&gt; 'Submit', value =&gt; 'Register' );

has '+unique_messages' =&gt;
  ( default =&gt; sub { { player_email =&gt;
                                  'Email already registered' } } );


no HTML::FormHandler::Moose;
__PACKAGE__-&gt;meta-&gt;make_immutable;

1
</pre>



<h2><span class="caps">DBIC</span> Model</h2>

<p>Notice that we're extending the <span class="caps">DBIC </span>model so we can easily create records in our players (think users) table.  The '+item_class' attribute is where we specifiy the <span class="caps">DBIC</span> Result class that we bind the form to.  In our case this is the Player class that corresponds to the player table in our database.  Player is synonymous with the more commonly found  user table where one has a username and password column.</p>

<h2>Form Field Types</h2>

<p>FormHandler has a Moose-like attribute declarer <b>has_field</b>.  This allows one to declare fields where the type is a <span class="caps">HTML</span>::FormHandler::Field such as '<b>Text</b>', '<b>Email</b>', '<b>Password</b>' etc.   These type declarations enable cheap and effective validation.  For example, a field with type Email will be checked using <b>Email::Valid</b>.  In addition we set the email field as <b>required</b> and <b>unique</b>.</p>

<h2>Render as a Table</h2>

<p>I've asked for the rendering to be in table form with the 'HTML::FormHandler::Render::Table role.</p>

<h1>Make the Form Available in a Controller</h1>

<p>In order to have an instance of the registration form object available in a Catalyst controller I do:</p>



<pre>
use Bracket::Form::Register;

has 'register_form' =&gt; (
	isa     =&gt; 'Bracket::Form::Register',
	is      =&gt; 'rw',
	lazy    =&gt; 1,
	default =&gt; sub { Bracket::Form::Register-&gt;new },
);
</pre>



<p>Later in a controller action I will be able to access the form via $self-&gt;register_form.</p>

<h1>  Use the Form in a Controller Action</h1>



<pre>
sub register : Global {
	my ( $self, $c ) = @_;

        # Stash the form and the template to render it
	$c-&gt;stash(
		template =&gt; 'form/auth/register.tt',
		form     =&gt; $self-&gt;register_form,
	);

        # Create an empty row object for the desired table
	my $new_player = $c-&gt;model('DBIC::Player')-&gt;new_result( {} );

        # Process the for with the parameters, a schema and a row object
	$self-&gt;register_form-&gt;process(
		item      =&gt; $new_player,
		params =&gt; $c-&gt;request-&gt;parameters,
	);

	# This returns on GET (new form) and a POSTed form that's invalid.
	return if !$self-&gt;register_form-&gt;is_valid;

	# At this stage the form has validated
	$c-&gt;flash-&gt;{status_msg} = 'Registration initiated';
	$c-&gt;response-&gt;redirect( $c-&gt;uri_for('/login') );
}
</pre>



<p>Here we have one action that handles both the <span class="caps">GET </span>and <span class="caps">POST </span>request methods of the  form.  On <span class="caps">GET, HTML</span>::FormHandler will see that there are no parameters to process and just return the form.  On <span class="caps">POST, </span>it will check that the parameters are valid and then process them accordingly.  In our case this means, create a new user record from the form fields where each form field that corresponds to a column in our player table will be used to populate the column.</p>

<h2>Stash the Form and Template</h2>

<p>We start the action body off by stashing the form and template that will be used to render it.  All we need in the template<sup class="footnote"><a href="http://www.catalyzed.org/2010/03/an-introduction-to-formhandler.html#fn2">2</a></sup> is:</p>



<pre>
[% form.render %]
</pre>



<h2>New Row Object </h2>

<p>Since we want to create a new record in our Player class, we create a new row object of that nature with <span class="caps">DBIC'</span>s <b>new_result()</b> method<sup class="footnote"><a href="http://www.catalyzed.org/2010/03/an-introduction-to-formhandler.html#fn3">3</a></sup>.</p>

<h2>Arguments to Process</h2>

<p>Next we process the form with the following key/value combinations:</p>


<ul>
<li>item := which gets our row object, $new_player, where we'll store the form data</li>
<li>params := the parameters in our context</li>
</ul>



<p>Note that since we're passing in a <span class="caps">DBIC </span>row object as our item the schema is inferred.  If one is passing in a primary key this can be done  by passing in the primary key as 'item_id' and additionally pass the schema.  For example:</p>



<pre>
$self-&gt;form-&gt;process(
    item_id =&gt; 1,
    params =&gt; $c-&gt;request-&gt;parameters,
    schema =&gt; $c-&gt;model('DBIC')-&gt;schema,
)
</pre>



<h2>Validation</h2>

<p>The form is then validated and returned in its orginal form if it's not valid.  Otherwise we have a successful registration and proceed to login<sup class="footnote"><a href="http://www.catalyzed.org/2010/03/an-introduction-to-formhandler.html#fn5">5</a></sup>.  </p>

<h1> Conclusion</h1>

<p>FormHandler enables one to efficiently define forms and bind them to a <span class="caps">DBIC </span>model.  In addition, it allows types to be declared on fields which are then used in validation.  It also supports other form field properties such as: <b>unique</b> and <b>required</b>.   In short, it does all that is needed for basic form handling without having to write a single line of <span class="caps">HTML.</span></p>


<h1>Footnotes</h1>

<p class="footnote" id="fn1"><sup>1</sup>  Instead of the proverbial 'MyApp', I'm using the application name 'Bracket'.  This is for a <span class="caps">NCAA </span>tournament bracket app. I'm cooking up.  Ping me if your interested in it.</p>

<p class="footnote" id="fn2"><sup>2</sup> We're using a Template Toolkit view.</p>

<p class="footnote" id="fn3"><sup>3</sup> The row is not actually inserted yet, just prepared to be.</p>

<p class="footnote" id="fn4"><sup>4</sup> When we pass a row object item to process() we don't need to specify the schema.</p>

<p class="footnote" id="fn5"><sup>5</sup> An upcoming article will discuss how to build a login form backed with authentication in Catalyst using FormHandler and <span class="caps">DBIC.</span></p>]]>
    </content>
</entry>

<entry>
    <title>Using Data::Manager with Template::Toolkit and Catalyst</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2010/02/using-datamanager-with-templatetoolkit-and-catalyst.html" />
    <id>tag:www.catalyzed.org,2010://1.79</id>

    <published>2010-02-12T20:21:21Z</published>
    <updated>2010-02-16T20:53:13Z</updated>

    <summary>Data::Manager is a really fantastic marriage of two very well thought out and uncoupled modules, Data::Verifier and Message::Stack. Data::Verifier does exactly what its name says, which is verifies data. You give it a hashref of constraints to verify against, and...</summary>
    <author>
        <name>Devin Austin</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=2</uri>
    </author>
    
        <category term="Catalyst" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="catalyst" label="catalyst" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="data" label="data" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="dbic" label="dbic" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="form" label="form" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="manager" label="manager" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="message" label="message" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="reflector" label="reflector" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="sensible" label="sensible" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="stack" label="stack" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="template" label="template" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="toolkit" label="toolkit" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="verifier" label="verifier" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<p><a href="http://search.cpan.org/~gphat/Data-Manager-0.06/lib/Data/Manager.pm">Data::Manager</a> is a really fantastic marriage of two very well thought out and uncoupled modules, <a href="http://search.cpan.org/perldoc?Data%3A%3AVerifier">Data::Verifier</a> and <a href="http://search.cpan.org/perldoc?Message%3A%3AStack">Message::Stack</a>.  Data::Verifier does exactly what its name says, which is verifies data.  You give it a hashref of constraints to verify against, and call ->validate on your data that you've passed in, and boom, data is verified with errors and filters.  Messages::Stack is again, another very aptly named module.  It gives you a programmatic interface to creating a stack of messages with a syslog flavor to them with regards to message level, scope, id, etc.  You can then, after creating a stack of messages, retrieve messages matching a scope, or a block of messages pertaining to a certain attribute of your data, search through the messages and grab the ones that match your search criteria, or get all of the messages.</p>
]]>
        <![CDATA[<p>So with that, I'm going to show you how Data::Manager allows you to use both of these modules to validate your data and create coherent messages in a manageable and scalable fashion.  For level playing field reasons, I'm going to be demonstrating with a Catalyst application I recently used these methods in.</p>

<p>I have set up an API controller to handle the CRUD interface to this application.  Data::Manager provided a perfect single source for data verification (beyond various form validation in front facing portions of the site) and message building for results.  Basically, the controller looks like this:</p>

<pre>
package Denzel::Controller::Users;

use Moose;
use namespace::autoclean;
BEGIN { extends 'Catalyst::Controller' }
use URI;
use Try::Tiny;
use Form::Sensible::Reflector::DBIC;
use Carp;
use Data::Dumper;
use DateTime;

## CLUE stuff

sub clue_base : Chained('/') PathPart('user') CaptureArgs(1) {
    my ( $self, $c, $userid ) = @_;
    $c->stash( userid => $userid );
}

sub cl_base : Chained('/') PathPart('users') CaptureArgs(0) {
    my ( $self, $c ) = @_;
}

sub create_user : Chained('cl_base') PathPart('new') Args(0) {
    my ( $self, $c ) = @_;
    my $reflector = Form::Sensible::Reflector::DBIC->create_form(
        {
            handle => $c->model('Database')->schema,
            form   => { name => "user" }
        }
    );
    $reflector->field('role')->value('member');
    $reflector->field('created_on')->value( DateTime->now );
    my $output;

    $reflector->add_field(
        {
            name        => 'captcha',
            field_class => 'Text',
            value       => $c->captcha_string
        }
    );
    $reflector->add_field( { name => 'Join', field_class => 'Trigger' } );
    my $renderer = Form::Sensible->get_renderer('HTML');

    if ( $c->req->param('Join') ) {
        $c->forward(qw/ Controller::API create_user /);
        $c->log->debug("Messages inside Users: " . Dumper $c->stash->{'messages'});
        if ( @{ $c->error } ) {
            $c->stash( errors => @{ $c->error } );
            $c->detach;
        }
        $c->stash( message => "Added successfully!");
    }

    $output = $renderer->render($reflector)->complete( '/users/new', 'POST' );
    $c->stash( form => $output );
}
</pre>

<p>Boom.  forward to the API controller if the form is valid, go on with ya bad self.</p>

<p>The final piece of this is the template.  I use Template::Toolkit because it's awesome and less hateful than the rest of the templating systems.  This took a bit of thought, so here's what I came up with:</p>

<pre>
&lt;div id=&quot;messages&quot;&gt;
                &lt;h2&gt;
                    [% message %]
                &lt;/h2&gt;
                &lt;h2&gt;
                    [% error %]
                &lt;/h2&gt;
                &lt;ul&gt;
                [% IF messages.has_messages %]
                &lt;h2&gt;Form Errors: &lt;/h2&gt;
                &lt;ul&gt;
                [% SET i = messages.count - 1 %]
                [% WHILE i &gt;= 0 %]
                &lt;li&gt;
                [% messages.get_message(i).subject %] 
                &lt;/li&gt;
                &lt;li&gt;
                [%  messages.get_message(i).id.replace('_', ' ') %]
                [% i = i - 1 %]
                [% END %]
                [% END %]
                &lt;/ul&gt;
            &lt;/div&gt;

</pre>

<p>And just for good measure, the create user template:</p>

<pre>
[% IF errors %]
&lt;div&gt;[% errors %]&lt;/div&gt;
[% END %]
[% IF success %]
&lt;div&gt;Thanks for joining! Check your email for your confirmation link.&lt;/div&gt;
&lt;div&gt;&lt;a href=&quot;[% c.uri_for_action('/users/clue/view_privileged_profile', user.userid) %]&quot;&gt;click here to edit your profile&lt;/a&gt;
[% END %]

[% UNLESS c.req.param('join') %]
&lt;h2&gt;Join Denzelfuckingwashington.com&lt;/h2&gt;
[% form %]
&lt;div&gt;&lt;img src=&quot;[% c.uri_for(&quot;/captcha&quot;)%]&quot; /&gt;&lt;/div&gt;
[% END %]

</pre>

<p>Bingo bango done.  Rock solid.  And yes, this is also a pitch for <a href="http://denzelfuckingwashington.com">denzelfuckingwashington.com</a> :-)</p>
]]>
    </content>
</entry>

<entry>
    <title>Look at Padre!</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2009/12/look-at-padre.html" />
    <id>tag:www.catalyzed.org,2009://1.77</id>

    <published>2009-12-03T16:37:17Z</published>
    <updated>2009-12-03T19:40:11Z</updated>

    <summary>For many years the favored editor for Perl developers fell under the same umbrella as the favored editor in *nix. A major fight between Vi and Emacs, and all the other options trailing behind somewhere. Over the past year, a...</summary>
    <author>
        <name>Jay Kuri</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=1</uri>
    </author>
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="cpan" label="cpan" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="padre" label="padre" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<p>For many years the favored editor for Perl developers fell under the same umbrella as the favored editor in *nix.  A major fight between Vi and Emacs, and all the other options trailing behind somewhere.  </p>

<p>Over the past year, a team of developers has been working to change that.  The result is the Padre editor, or the <strong>P</strong>erl <strong>A</strong>pplication <strong>D</strong>evelopment and <strong>R</strong>efactoring <strong>E</strong>nvironment.  The Padre team recently released their 0.5 revision and let me tell you, <strong><em>it is fantastic.</em></strong> </p>

<p>With the 0.5 release there are two particularly interesting developments.  They are a <a href="http://ali.as/Padre.dmg">Mac standalone package</a> and a self-contained <a href="http://padre.perlide.org/download.html">Windows package</a>. This makes Padre extremely easy to install on the two most common desktop systems and puts it on level ground with all your other editing options.  If you don't read another word, grab a copy and try it.
* (... screenshot after the break)*</p>
]]>
        <![CDATA[<p>Being a long time vi user (And more recently a Textmate convert) I was not really in the market for a new editor.  That said, the new release is a vast improvement over the Padre of even just a few months ago.  In my opinion Padre is 100% ready for daily use, and the Padre team are committed to improving it even further. </p>

<p>Kudos to the Padre team.  Padre 0.5 has done what I thought was unthinkable, it has threatened to topple Textmate as my primary editor.  My prediction the 1.0 release of Padre will be the gold standard editor for Perl developers.  It's already well on it's way.  </p>

<p>If you haven't tried it, grab the <a href="http://ali.as/Padre.dmg">package</a> for your <a href="http://padre.perlide.org/download.html">system</a> (or do the install via CPAN) and take it for a spin.  You won't be disappointed.</p>

<p>Oh, and as promised:</p>

<p><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.catalyzed.org/assets_c/2009/12/padre-45.html" onclick="window.open('http://www.catalyzed.org/assets_c/2009/12/padre-45.html','popup','width=964,height=640,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.catalyzed.org/assets_c/2009/12/padre-thumb-450x298-45.png" width="450" height="298" alt="padre.png" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></a></span></p>
]]>
    </content>
</entry>

<entry>
    <title>Fnargh::Form::Auto (Soon to be HTML::FormHandler::Reflector::DBIC)</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2009/11/fnarghformauto-soon-to-be-htmlformhandlerreflectordbic.html" />
    <id>tag:www.catalyzed.org,2009://1.75</id>

    <published>2009-11-13T16:49:48Z</published>
    <updated>2009-11-13T22:31:33Z</updated>

    <summary>I&apos;ve never really liked dealing with creating forms. You have to write a butt load of tedious HTML, validate it, and then return error messages as needed. If you want it to be fancy and pretty, you have to write...</summary>
    <author>
        <name>Devin Austin</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=2</uri>
    </author>
    
        <category term="Catalyst" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="catalyst" label="catalyst" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="dbixclass" label="dbix::class" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="formhandler" label="formhandler" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="forms" label="forms" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="html" label="html" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="htmlformhandler" label="html::formhandler" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="moose" label="Moose" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<p>I've never really liked dealing with creating forms.  You have to write a butt load of tedious HTML, validate it, and then return error messages as needed.  If you want it to be fancy and pretty, you have to write a bunch of CSS to put your error messages where you want and make them shiny.  Luckily, there are <a href="http://search.cpan.org/~cfranks/HTML-FormFu-0.05001/lib/HTML/FormFu.pm">things</a> <a href="http://search.cpan.org/~markstos/Data-FormValidator-4.63/lib/Data/FormValidator.pm">to</a> <a href="http://search.cpan.org/~gshank/HTML-FormHandler-0.28001/lib/HTML/FormHandler.pm">handle</a> <a href="http://search.cpan.org/~hank/Form-Processor-0.19/lib/Form/Processor.pm">this</a>.</p>

<p>Being a Moose fanatic, I am most partial to the latter, <a href="http://search.cpan.org/~gshank/HTML-FormHandler-0.28001/lib/HTML/FormHandler.pm">HTML::FormHandler</a>.  It's extremely easy to use, and requires zero configuration file crap.  You get validation as Moose types/constraints, it's very cool.</p>

<p>So, back to me hating having to build forms.  This includes building a form for something that already has enough information to build a form <em>from</em>, say, a database schema.  My dream has been to be able to read a database schema (preferably <a href="http://search.cpan.org/~ribasushi/DBIx-Class-0.08112/lib/DBIx/Class.pm">DBIx::Class</a>), and generate a form based on the data types specified in said schema.  This is completely doable! Heck, even <em>I</em> drafted up some code to get some preliminary form fields from a database.  The following is from the CMS I'm working on, using HTML::FormHandler and DBIx::Class to get things done.  This is extremely proof of concept code, and doesn't actually have any logic to determine what <em>kind</em> of form element a given schema entity should be.  That, however, should be fairly trivial and I will undoubtedly be writing a follow up to that effect.  Go here to check out the source: <a href="http://gist.github.com/230652">http://gist.github.com/230652</a>. Enjoy.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Fun With JSON Config Files!</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2009/11/fun-with-json-config-files.html" />
    <id>tag:www.catalyzed.org,2009://1.73</id>

    <published>2009-11-09T07:24:32Z</published>
    <updated>2009-11-09T07:34:20Z</updated>

    <summary>So I recently decided to convert the config file for a new app I&apos;m working on to JSON. Why? Well for one, it&apos;s a lot easier to express perl data structures in, and it&apos;s also extremely easy to read. Check...</summary>
    <author>
        <name>Devin Austin</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=2</uri>
    </author>
    
    <category term="catalyst" label="catalyst" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="config" label="config" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="json" label="json" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<p>So I recently decided to convert the config file for a new <a href="http://github.com/dhoss/fnargh">app</a> I'm working on to JSON.  Why?  Well for one, it's a lot easier to express perl data structures in, and it's also extremely easy to read.  Check it out!</p>

<pre><code>{
    "name": "Fnargh",
    "Model::Database": {
        "connect_info": [
            "dbi:SQLite:fnargh.db",
            "",
            "" 
        ] 
    } ,
    "session": {
        "flash_to_stash": "1" 
    }
}
</code></pre>

<p>Started off a bit rocky, but thanks to <a href="http://www.jsonlint.com">http://www.jsonlint.com</a> I was able to pick at my config file until it was valid.  It formats it nicely for you as well!</p>

<p>The best part? You can take the perl data that you use in your Catalyst app, and do something like this: </p>

<pre>
squishface:~ dhoss$ perl -e "use JSON; print to_json({ my_data => [ 'thing1', 'thing2', 'thing3' ] });"
{"my_data":["thing1","thing2","thing3"]}
</pre>

<p>JSON formatted for your config! </p>
]]>
        

    </content>
</entry>

<entry>
    <title>System Call Debugging with (s|k|d(trace|truss)) (that&apos;s strace, ktrace, dtrace or dtruss)</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2009/11/system-call-debugging-with-skdtracetruss-thats-strace-ktrace-dtrace-or-dtruss.html" />
    <id>tag:www.catalyzed.org,2009://1.70</id>

    <published>2009-11-06T19:17:00Z</published>
    <updated>2009-11-06T19:07:57Z</updated>

    <summary>Recently while working on getting tests done for Catalyst::Devel so it could be shipped, and I absolutely could not figure out how to get the test for the development server to work. So, I queried #catalyst-dev about it, and my...</summary>
    <author>
        <name>Devin Austin</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=2</uri>
    </author>
    
        <category term="Catalyst" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="calls" label="calls" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="catalyst" label="catalyst" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="debugging" label="debugging" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="devel" label="devel" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="dtruss" label="dtruss" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ipc" label="ipc" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="strace" label="strace" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="system" label="system" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<p>Recently while working on getting tests done for Catalyst::Devel so it could be shipped, and I absolutely could not figure out how to get the test for the development server to work.  So, I queried #catalyst-dev about it, and my good friend <a href="http://www.shadowcat.co.uk/blog/matt-s-trout/">mst</a> told me to use strace to figure out what was going on behind the scenes.  In this case, I used dtruss since I'm a Mac user and for some reason the usual *nix tool doesn't work on the Mac platform.</p>

<p>Basically, what went down was this: </p>

<ol>
<li>sudo dtruss -f prove -l t/author/optional_http-server.t</li>
<li>a whole load of rather cryptic output (see below for a snippet)</li>
<li>analysis and correction</li>
</ol>

<p>What I found was that since the Catalyst development server is chock full of system calls that are chock full of information on what's going on (and going wrong) behind the scenes, dtruss was the perfect tool for grabbing messages being relayed between processes and not necessarily being spewed out to my terminal.  Here's a small snippet of the problem area I (well, mst actually) discovered:</p>

<p><code>
46665/0x117e04:  stat64("/opt/local/lib/perl5/vendor<em>perl/Catalyst/ScriptRunner.pm\0", 0x7FFF5FBFEE90, 0xFFFFFFFFFFFFFFFF)       = -1 Err#2
46665/0x117e04:  stat64("/opt/local/lib/perl5/5.8.9/darwin-2level/Catalyst/ScriptRunner.pmc\0", 0x7FFF5FBFEF20, 0x0)         = -1 Err#2
46665/0x117e04:  stat64("/opt/local/lib/perl5/5.8.9/darwin-2level/Catalyst/ScriptRunner.pm\0", 0x7FFF5FBFEE90, 0xFFFFFFFFFFFFFFFF)       = -1 Err#2
46665/0x117e04:  stat64("/opt/local/lib/perl5/5.8.9/Catalyst/ScriptRunner.pmc\0", 0x7FFF5FBFEF20, 0x0)       = -1 Err#2
46665/0x117e04:  stat64("/opt/local/lib/perl5/5.8.9/Catalyst/ScriptRunner.pm\0", 0x7FFF5FBFEE90, 0xFFFFFFFFFFFFFFFF)         = -1 Err#2
46665/0x117e04:  stat64("./Catalyst/ScriptRunner.pmc\0", 0x7FFF5FBFEF20, 0x0)    = -1 Err#2
46665/0x117e04:  stat64("./Catalyst/ScriptRunner.pm\0", 0x7FFF5FBFEE90, 0xFFFFFFFFFFFFFFFF)      = -1 Err#2
46665/0x117e04:  write</em>nocancel(0x2, "Can't locate Catalyst/ScriptRunner.pm in @INC (@INC contains: /Users/dhoss/web-devel/Cat-Runtime-5.8/t/author/../../lib /Users/dhoss/web-devel/Cat-Runtime-5.8/lib /opt/local/lib/perl5/site<em>perl/5.8.9/darwin-2level /opt/local/lib/perl5/site</em>perl/5.8.9 /opt/", 0x2D0)
</code></p>

<p>That's just a snippet.  Somewhat cryptic, but it's <em>all</em> right there. Check out this line: <code>46665/0x117e04:  write<em>nocancel(0x2, <strong>"Can't locate Catalyst/ScriptRunner.pm in @INC (@INC contains: /Users/dhoss/web-devel/Cat-Runtime-5.8/t/author/../../lib /Users/dhoss/web-devel/Cat-Runtime-5.8/lib /opt/local/lib/perl5/site</em>perl/5.8.9/darwin-2level /opt/local/lib/perl5/site_perl/5.8.9 /opt/"</strong>, 0x2D0)</code>.  Derp!  I was running this test in Catalyst::Runtime trunk/ that doesn't have my ScriptRunner classes merged yet.  So, I reran this test (using dtruss -f again) under my branch, found out that the options being passed to the development server were incorrect, corrected, svn committed, and can now take another step (finally) toward shipping Catalyst::Devel!</p>
]]>
        

    </content>
</entry>

<entry>
    <title>MT+Plack on nginx = love</title>
    <link rel="alternate" type="text/html" href="http://www.catalyzed.org/2009/11/mtplack-on-nginx-love.html" />
    <id>tag:www.catalyzed.org,2009://1.71</id>

    <published>2009-11-06T18:45:00Z</published>
    <updated>2009-11-06T22:02:50Z</updated>

    <summary>There&apos;s a new kid on the block for web application development, and it&apos;s called Plack. I&apos;m not going to go into depth on explaining it here, as the website listed previously does a stellar job of that, but I&apos;m going...</summary>
    <author>
        <name>Devin Austin</name>
        <uri>http://www.catalyzed.org/mt/mt-cp.cgi?__mode=view&amp;blog_id=1&amp;id=2</uri>
    </author>
    
        <category term="Catalyst" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="catalyst" label="catalyst" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="movable" label="movable" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="plack" label="plack" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="psgi" label="psgi" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="type" label="type" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.catalyzed.org/">
        <![CDATA[<p>There's a new kid on the block for web application development, and it's called <a href="http://www.plackperl.org">Plack</a>.  I'm not going to go into depth on explaining it here, as the website listed previously does a stellar job of that, but I'm going to explain and talk about what got me started on it, and what made me love it.</p>

<p>I've been a pretty avid <a href="http://www.movabletype.org">MovableType</a> fan since I first got it running.  It Just Works(tm).  I've always ran it under Apache, however, so when I made the big and permanent transition to nginx, I was befuddled as to how to get it to run under my new toy. A kind sir by the name of <a href="http://www.coldhardcode.com">Jay Shirley</a> recommended I use Plack to get my old love running under nginx.  I talked to the creator of this mystical new being, <a href="http://bulknews.vox.com/">Tatsuhiko Miyagawa</a> on its IRC channel, #plack.  We went back and forth for a few iterations until w(h)e got his mt.psgi script (listed <a href="http://gist.github.com/227584">here</a>) working so that MT would be okay with new installs. </p>

<p>The result: A mostly working MovableType installation!  The only problem is, I have a MT database dump from MySQL that I either A) need to convert the data portion of the dump to something PostgreSQL (what I've converted to for life) will like, or B) suck it up and set up a MySQL instance for this one app. MT itself runs just fine, it's completely my fault that anything on the database side doesn't work.  Miyagawa reports that previous installations work just fine with this, so, as I said, I will need to investigate which route I want to take to get this data into a database for MT.</p>

<p>Either way, my experience was fantastic.  Plack is really easy to set up.  All the work is done for you, and you can still run things under FastCGI (if you're so inclined).  It's a great bridge between server software and a web application, so we're not stranded somewhere in between holding on to the connecting ends of a bridge screaming "HOLY FUCK THIS HURTS AND GOD I HOPE IT HOLDS TOGETHER IF WE HAVE TO CHANGE ANYTHING".</p>

<p>Kudos to you miyagawa, I'm pretty sold on using this from here on out for web apps I write in the future (mostly Catalyst based, for which we have <a href="http://search.cpan.org/~miyagawa/Catalyst-Engine-PSGI-0.05/lib/Catalyst/Engine/PSGI.pm">Catalyst::Engine::PSGI</a>!)</p>

<p><strong>UPDATE:</strong> Here's the configuration I'm using for nginx: <a href="http://wiki.catalyzed.org/codesamples/dhoss/plack_nginx_conf">http://wiki.catalyzed.org/codesamples/dhoss/plack<em>nginx</em>conf</a></p>
]]>
        

    </content>
</entry>

</feed>
