<?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>Rambles &#187; Perl</title>
	<atom:link href="http://rambles.bearcircle.net/category/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://rambles.bearcircle.net</link>
	<description>Programming, Poker, and Politics.  Just Another voice in the electronic wilderness</description>
	<lastBuildDate>Mon, 26 Jul 2010 16:53:48 +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>Moving On</title>
		<link>http://rambles.bearcircle.net/2009/06/05/moving-on/</link>
		<comments>http://rambles.bearcircle.net/2009/06/05/moving-on/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 16:02:40 +0000</pubDate>
		<dc:creator>Lance</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Catalyst]]></category>

		<guid isPermaLink="false">http://rambles.bearcircle.net/2009/06/05/moving-on/</guid>
		<description><![CDATA[I just unsubscribed from the CGI::Application mailing list.&#160; I no longer use CGI::App and the mails were just cluttering my inbox. My first Perl CGi script was written using plain ol&#8217; CGI.pm many years ago.&#160; I ran across it again recently and winced when I read the code.&#160; I saw messes of nested function calls [...]]]></description>
			<content:encoded><![CDATA[<p>I just unsubscribed from the <a href="http://search.cpan.org/%7Emarkstos/CGI-Application-4.21/lib/CGI/Application.pm">CGI::Application</a> mailing list.&nbsp; I no longer use CGI::App and the mails were just cluttering my inbox. My first Perl CGi script was written using plain ol&#8217; <a href="http://search.cpan.org/dist/CGI.pm/">CGI.pm</a> many years ago.&nbsp; I ran across it again recently and winced when I read the code.&nbsp; I saw messes of nested function calls to generate the HTML, manually processing form data, etc.&nbsp; Scary stuff, but it worked.&nbsp; Then I found CGI::Application and HTML::Template and gleefully jumped on board.&nbsp; It made my life much easier.&nbsp; About 2 years ago I encountered <a href="http://search.cpan.org/%7Eflora/Catalyst-Runtime-5.80004/lib/Catalyst.pm">Catalyst </a>and started learning it.&nbsp; The applications I was writing were growing more complex and CGI::Application was becoming part of the problem instead of the solution, so Catalyst was attractive to me and offered a very flexible, powerful platform for developing web applications.&nbsp; I&#8217;ve been using it ever since and have deployed several large application using it.&nbsp; So, with a fond farewell, I signed off the CGI::Application mailing list.</p>
]]></content:encoded>
			<wfw:commentRss>http://rambles.bearcircle.net/2009/06/05/moving-on/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>InflateColumn::File vs. InflateColumn::FS</title>
		<link>http://rambles.bearcircle.net/2009/05/24/inflatecolumnfile-vs-inflatecolumnfs/</link>
		<comments>http://rambles.bearcircle.net/2009/05/24/inflatecolumnfile-vs-inflatecolumnfs/#comments</comments>
		<pubDate>Sun, 24 May 2009 21:12:12 +0000</pubDate>
		<dc:creator>Lance</dc:creator>
				<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://rambles.bearcircle.net/2009/05/24/inflatecolumnfile-vs-inflatecolumnfs/</guid>
		<description><![CDATA[In my last Perl post I said IC::File fits my needs better and let me serve files using Static::Simple.&#160; Well, it did that, but issues with properly handling deletes and updates forced me to re-evaluate my decision and switch to InflateColumn::FS.
The application will manage an archive of discussion papers, including abstracts, BibTeX citations, and supplemental [...]]]></description>
			<content:encoded><![CDATA[<p>In my last Perl post I said IC::File fits my needs better and let me serve files using Static::Simple.&nbsp; Well, it did that, but issues with properly handling deletes and updates forced me to re-evaluate my decision and switch to InflateColumn::FS.</p>
<p>The application will manage an archive of discussion papers, including abstracts, BibTeX citations, and supplemental data files.&nbsp; I need to store uploaded files and provide links to download them from the application.</p>
<p>Retooling for IC::FS included subclassing IC::FS to tune its operation for my needs and writing my own utility method to serve up the files instead of using Static::Simple.&nbsp; IC::FS uses UUIDs for filenames in the filesystem and I want the original filenames in the URLs in the application.&nbsp; Serving up files directly isn&#8217;t difficult so I wrote my own Catalyst controller method, cribbing code from Static::Simple:</p>
<pre>
sub send_file : Private
{
    my ($self, $c, $file, $filename) = @_;

    my $type;
    my $stat = $file-&gt;stat;

    # Get MIME Type - swiped from Static::Simple
    if ( $filename =~ /.*\.(\S{1,})$/xms )
    {
        my $ext = $1;
        my $types = MIME::Types-&gt;new(only_complete =&gt; 1);
        $type = $types-&gt;mimeTypeOf($ext);
    }
    else
    {
        # Don't know type, so punt
        $type = 'text/plain';
    }

    $c-&gt;res-&gt;headers-&gt;content_type($type);
    $c-&gt;res-&gt;headers-&gt;content_length($stat-&gt;size);
    $c-&gt;res-&gt;headers-&gt;last_modified($stat-&gt;mtime);
    $c-&gt;res-&gt;headers-&gt;header("Content-Disposition" =&gt;
                             "filename=\"$filename\"");

    # More code swiped from Static::Simple
    if ( Catalyst-&gt;VERSION le '5.33' )
    {
        # old File::Slurp method
        my $content = File::Slurp::read_file( $file );
        $c-&gt;res-&gt;body( $content );
    }
    else
    {
        # new method, pass an IO::File object to body
        my $fh = $file-&gt;openr;
        if ( defined $fh )
        {
            binmode $fh;
            $c-&gt;res-&gt;body( $fh );
        }
        else
        {
            Catalyst::Exception-&gt;throw(
                                       message =&gt; "Unable to open $file for reading" );
        }
    }
    return 1;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://rambles.bearcircle.net/2009/05/24/inflatecolumnfile-vs-inflatecolumnfs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On Not Reinventing the Wheel</title>
		<link>http://rambles.bearcircle.net/2009/05/12/on-not-reinventing-the-wheel/</link>
		<comments>http://rambles.bearcircle.net/2009/05/12/on-not-reinventing-the-wheel/#comments</comments>
		<pubDate>Tue, 12 May 2009 05:07:15 +0000</pubDate>
		<dc:creator>Lance</dc:creator>
				<category><![CDATA[General Assembly]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[cpan]]></category>
		<category><![CDATA[uuaga09]]></category>

		<guid isPermaLink="false">http://rambles.bearcircle.net/2009/05/12/reinventing-the-wheel/</guid>
		<description><![CDATA[Last year I wrote a Catalyst-based application to manage the workflow for the team of reporters, editors, and publishers providing web reporting for the the annual Unitarian Universalist General Assembly.  This includes tracking each event at GA, assigning reporters, photographers, videographers, and managing the writing/editing/publishing workflow for each article to be posted on the GA [...]]]></description>
			<content:encoded><![CDATA[<p>Last year I wrote a <a href="http://www.catalystframework.org/">Catalyst</a>-based application to manage the workflow for the team of reporters, editors, and publishers providing web reporting for the the annual <a href="http://www.uua.org/events/generalassembly/">Unitarian Universalist General Assembly</a>.  This includes tracking each event at GA, assigning reporters, photographers, videographers, and managing the writing/editing/publishing workflow for each article to be posted on the GA website.</p>
<p>I didn&#8217;t know about <a href="http://search.cpan.org/%7Eribasushi/DBIx-Class-0.08102/lib/DBIx/Class/InflateColumn/File.pm">DBIx::Class::InflateColumn::File</a> at the time, so I wrote my own system using <a href="http://search.cpan.org/%7Eash/Catalyst-Model-File-0.07/">Catalyst::Model::File</a> to store the uploaded files.  It was a mild pain in the ass to deal with the files separately from the DB model, but it worked and got the job done.</p>
<p>Lately, I&#8217;ve been working on another application that requires uploading and storing files:  a discussion paper archive and search system for the <a href="http://www.stat.duke.edu/">Department of Statistical Science</a> at Duke University.  Again, I was struggling with using <a href="http://search.cpan.org/%7Eash/Catalyst-Model-File-0.07/">Catalyst::Model::File</a> to store the uploaded manuscripts and associated data files.  I don&#8217;t like using C::M::File because it breaks the model paradigm.  I&#8217;d rather put all the data for each discussion paper in the DBIx::Class based DB model I built.  I&#8217;m thinking of writing some command line utility scripts for the archive and using C::M::File binds me to Catalyst in ways I don&#8217;t want.  So I went looking.</p>
<p>I saw discussion of <a href="http://search.cpan.org/%7Emmims/DBIx-Class-InflateColumn-FS/lib/DBIx/Class/InflateColumn/FS.pm">DBIx::Class::InflateColumn::FS</a> on the Catalyst mailing list and started investigating it.  Then I found <a href="http://search.cpan.org/%7Eribasushi/DBIx-Class-0.08102/lib/DBIx/Class/InflateColumn/File.pm">DBIx::Class::InflateColumn::File</a>.  Both provide the filesystem-based storage of files tied into my DB model I need, but I&#8217;m going to use InflateColumn::File.  It fits my needs better and lets me serve up the files using <a href="http://search.cpan.org/%7Eflora/Catalyst-Plugin-Static-Simple-0.21/lib/Catalyst/Plugin/Static/Simple.pm">Static::Simple</a> in a straightforward manner.</p>
<p>I love the <a href="http://search.cpan.org/">CPAN</a>!  It gave me not one, but two!, good alternatives to Catalyst::Model::File, and I don&#8217;t have to write it.   I only wish I&#8217;d noticed InflateColumn::File last year.</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=9aa85621-445a-84f1-bd4e-889d859e933f" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://rambles.bearcircle.net/2009/05/12/on-not-reinventing-the-wheel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
