<?xml version="1.0" encoding="UTF-8"?>
<feed
  xmlns="http://www.w3.org/2005/Atom"
  xmlns:thr="http://purl.org/syndication/thread/1.0"
  xml:lang="en"
   >
  <title type="text">Doug Latornell</title>
  <subtitle type="text"></subtitle>

  <updated>2012-05-03T22:46:17Z</updated>
  <generator uri="http://blogofile.com/">Blogofile</generator>

  <link rel="alternate" type="text/html" href="http://douglatornell.ca/blog" />
  <id>http://douglatornell.ca/blog/feed/atom/</id>
  <link rel="self" type="application/atom+xml" href="http://douglatornell.ca/blog/feed/atom/" />
  <entry>
    <author>
      <name></name>
      <uri>http://douglatornell.ca/blog</uri>
    </author>
    <title type="html"><![CDATA[Blogofile Improvements]]></title>
    <link rel="alternate" type="text/html" href="http://douglatornell.ca/blog/2012/05/03/blogofile-improvements" />
    <id>http://douglatornell.ca/blog/2012/05/03/blogofile-improvements</id>
    <updated>2012-05-03T19:42:33Z</updated>
    <published>2012-05-03T19:42:33Z</published>
    <category scheme="http://douglatornell.ca/blog" term="python" />
    <category scheme="http://douglatornell.ca/blog" term="blog maintenance" />
    <category scheme="http://douglatornell.ca/blog" term="blogofile" />
    <summary type="html"><![CDATA[Blogofile Improvements]]></summary>
    <content type="html" xml:base="http://douglatornell.ca/blog/2012/05/03/blogofile-improvements"><![CDATA[<div class="document">
<p>I finally got around to fixing a couple of minor annoyances I have with
<a class="reference external" href="http://www.blogofile.com/">Blogofile</a>.
These fixes apply to the <a class="reference external" href="https://github.com/EnigmaCurry/blogofile/branches/plugins">plugins</a> development branch of Blogofile
and the <a class="reference external" href="https://github.com/EnigmaCurry/blogofile_blog">Blogofile_blog</a> plugin,
but they should be easily backport-able to the Blogofile master branch.
I opened pull requests for these changes on Github
and I'm happy to report that <a class="reference external" href="http://twitter.com/#!/EnigmaCurry">&#64;EnigmaCurry</a> merged the Blogofile_blog ones
within hours!
But since Blogofile development and this blog have been languishing
for a while,
I figured I should write about the changes here.</p>
<p>Using Python 2.7 and 3.2 with the <tt class="docutils literal">PYTHONWARNINGS</tt> environment
variable set to <tt class="docutils literal">default</tt>
reveals that both Blogofile and the Blogofile_blog plugin raise
<tt class="docutils literal">ResourceWarning</tt> exceptions when the <tt class="docutils literal">blogofile build</tt> command is run.
Admittedly, this is a really minor issue,
but seeing a screen full of tracebacks every time I build my site is
annoying,
and it can obscure more serious problems.
Those warnings are easily silenced by changing the offending
<tt class="docutils literal">open</tt> statements to use <tt class="docutils literal">with</tt> statement context managers.
The fix for Blogofile is in <a class="reference external" href="https://github.com/EnigmaCurry/blogofile/pull/119">pull request 119</a>
and the one for Blogofile_blog is in <a class="reference external" href="https://github.com/EnigmaCurry/blogofile_blog/pull/7">pull request 7</a>.</p>
<p>The <tt class="docutils literal">blogofile blog create post</tt> command creates a file with the extension
<tt class="docutils literal">.markdown</tt> by default
but Blogofile also supports <a class="reference external" href="http://docutils.sourceforge.net/rst.html">RST</a> and <a class="reference external" href="http://textile.thresholdstate.com/">Textile</a> markup.
I use RST and really want my newly created post files to have the extension
<tt class="docutils literal">.rst</tt> so that emacs goes to <tt class="docutils literal"><span class="pre">rst-mode</span></tt> automatically when
I open a post file for editing.
Again,
a minor annoyance,
and my fix was easily implemented.
I chose to add a <tt class="docutils literal">blog.post.default_markup</tt> config option.
With <tt class="docutils literal">blog.post.default_markup = 'rst'</tt> in my site's <tt class="docutils literal">_config.py</tt> file
my new posts get the <tt class="docutils literal">.rst</tt> extension I want.
If <tt class="docutils literal">blog.post.default_markup</tt> is not set the created post file extension
defaults to <tt class="docutils literal">.markdown</tt> as before.
This feature is in <a class="reference external" href="https://github.com/EnigmaCurry/blogofile_blog/pull/8">pull request 8</a>.</p>
<p>I really like Blogofile
and using it's plugins branch was my spur to get serious about using
Python 3 and blogging again.
So, I'm really happy to see &#64;EnigmaCurry accepting pull requests again
on the project. Hooray!!</p>
</div>
]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://douglatornell.ca/blog</uri>
    </author>
    <title type="html"><![CDATA[CSV Downloads from Web Apps]]></title>
    <link rel="alternate" type="text/html" href="http://douglatornell.ca/blog/2012/02/09/csv-downloads-from-pylons" />
    <id>http://douglatornell.ca/blog/2012/02/09/csv-downloads-from-pylons</id>
    <updated>2012-02-09T21:34:51Z</updated>
    <published>2012-02-09T21:34:51Z</published>
    <category scheme="http://douglatornell.ca/blog" term="python" />
    <category scheme="http://douglatornell.ca/blog" term="pylons" />
    <summary type="html"><![CDATA[CSV Downloads from Web Apps]]></summary>
    <content type="html" xml:base="http://douglatornell.ca/blog/2012/02/09/csv-downloads-from-pylons"><![CDATA[<div class="document">
<p>One of the users of an intranet app I maintain was using copy/paste to
put data from the app into Excel. She asked if there was a better
way. The pages she was copying from have tables of datastore objects,
so adding a CSV download feature was an obvious solution. Providing
that feature turned out to be pretty easy with the help of the
<a class="reference external" href="http://docs.python.org/library/stringio.html">StringIO</a> and <a class="reference external" href="http://docs.python.org/library/csv.html">csv</a> modules in the standard library.</p>
<p>While the code below is from a Pylons controller class, I can't see it
being difficult to implement this in Django, Pyramid, or other web
framework stacks.</p>
<p>The request handler for the CSV download looks like:</p>


<div class="pygments_default"><pre><span class="kn">import</span> <span class="nn">cString</span>
<span class="kn">import</span> <span class="nn">csv</span>

<span class="k">def</span> <span class="nf">csv_download</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">...</span><span class="p">):</span>
    <span class="n">csv_buffer</span> <span class="o">=</span> <span class="n">cStringIO</span><span class="o">.</span><span class="n">StringIO</span><span class="p">()</span>
    <span class="n">csv_writer</span> <span class="o">=</span> <span class="n">csv</span><span class="o">.</span><span class="n">writer</span><span class="p">(</span><span class="n">csv_buffer</span><span class="p">)</span>
    <span class="n">header</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_build</span> <span class="n">csv_header</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
    <span class="n">csv_writer</span><span class="o">.</span><span class="n">writerow</span><span class="p">(</span><span class="n">header</span><span class="p">)</span>
    <span class="n">query_result</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_data_for_csv</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">query_result</span><span class="p">:</span>
        <span class="n">row</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_build_csv_row</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
        <span class="n">csv_writer</span><span class="o">.</span><span class="n">writerow</span><span class="p">(</span><span class="n">row</span><span class="p">)</span>
    <span class="n">content</span> <span class="o">=</span> <span class="n">csv_buffer</span><span class="o">.</span><span class="n">getvalue</span><span class="p">()</span>
    <span class="n">csv_buffer</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
    <span class="n">response</span><span class="o">.</span><span class="n">content_type</span> <span class="o">=</span> <span class="s">&#39;text/csv; charset=utf-8&#39;</span>
    <span class="n">response</span><span class="o">.</span><span class="n">content_disposition</span> <span class="o">=</span> <span class="p">(</span>
        <span class="s">&#39;attachment; filename=&quot;your_file.csv&quot;&#39;</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">content</span>
</pre></div>



<p>This method uses <tt class="docutils literal">StringIO</tt> to set up a file-like memory buffer, and
instantiates a default CSV writer to write to the buffer. Next we
build the header row and write it to the buffer. Then we get an
iterator for the content that we want to write the the CSV file from
the datastore, and format and write it to the buffer, one line at a
time. Finally we get the CSV data from the buffer, set the response
headers appropriately, and return the CSV data for download.</p>
<p>One thing I'm uncertain about: Is it necessary to explicitly call
<tt class="docutils literal">close</tt> method on a <tt class="docutils literal">StringIO</tt> instance, or could I just do:</p>


<div class="pygments_default"><pre><span class="k">return</span> <span class="n">csv_buffer</span><span class="o">.</span><span class="n">getvalue</span><span class="p">()</span>
</pre></div>



<p>and let garbage collection take care of releasing the memory allocated
for <tt class="docutils literal">csv_buffer</tt>?</p>
<p>To get Excel to play nice with UTF-8 encoded data it's necessary to
include 3 specific bytes as a Byte Order Mark (BOM) at the beginning
of the file. I did that by prepending them to the heading string for
the first column:</p>


<div class="pygments_default"><pre><span class="k">def</span> <span class="nf">_build_csv_header</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">...</span><span class="p">)</span>
    <span class="n">UTF_8_BOM</span> <span class="o">=</span> <span class="s">&#39;</span><span class="se">\xef\xbb\xbf</span><span class="s">&#39;</span>
    <span class="n">header</span> <span class="o">=</span> <span class="p">[</span>
        <span class="n">UTF_8_BOM</span> <span class="o">+</span> <span class="s">&#39;Column 1 Heading&#39;</span><span class="p">,</span>
        <span class="o">...</span>
    <span class="p">]</span>
    <span class="k">return</span> <span class="n">header</span>
</pre></div>



<p>Building the content for each row of the CSV file is just a matter of
formatting each query result into an array of strings. Fields
containing non-ASCII characters stored as Unicode need to be encoded
to UTF-8:</p>


<div class="pygments_default"><pre><span class="k">def</span> <span class="nf">_build_csv_row</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">result</span><span class="p">)</span>
    <span class="n">row</span> <span class="o">=</span> <span class="p">[</span>
        <span class="n">result</span><span class="o">.</span><span class="n">column_1_value</span><span class="p">,</span>
        <span class="s">&#39;{:%Y-%m-</span><span class="si">%d</span><span class="s">}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="n">some_date</span><span class="p">)</span>
        <span class="o">...</span>
        <span class="n">result</span><span class="o">.</span><span class="n">unicode_value</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s">&#39;utf-8&#39;</span><span class="p">),</span>
        <span class="o">...</span>
    <span class="p">]</span>
    <span class="k">return</span> <span class="n">row</span>
</pre></div>



<p>I had an additional complication to deal with. The data for one of the
CSV columns is stored in the database as HTML fragments that may
contain non-ASCII characters. That data had to be rendered to Unicode
before it could be added to the CSV row (encoded as UTF-8). It turns
out that the Python standard library provides a fairly painless way of
handling that complication too, but I'll leave that for another post.</p>
</div>
]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://douglatornell.ca/blog</uri>
    </author>
    <title type="html"><![CDATA[YAML Fixtures in Django Tests]]></title>
    <link rel="alternate" type="text/html" href="http://douglatornell.ca/blog/2012/01/23/yaml-fixtures-in-django-tests" />
    <id>http://douglatornell.ca/blog/2012/01/23/yaml-fixtures-in-django-tests</id>
    <updated>2012-01-23T16:14:25Z</updated>
    <published>2012-01-23T16:14:25Z</published>
    <category scheme="http://douglatornell.ca/blog" term="python" />
    <category scheme="http://douglatornell.ca/blog" term="testing" />
    <category scheme="http://douglatornell.ca/blog" term="django" />
    <summary type="html"><![CDATA[YAML Fixtures in Django Tests]]></summary>
    <content type="html" xml:base="http://douglatornell.ca/blog/2012/01/23/yaml-fixtures-in-django-tests"><![CDATA[<div class="document">
<p>I have a Django project called <a class="reference external" href="http://randopony.randonneurs.bc.ca/">RandoPony</a> that handles event
registration for the <a class="reference external" href="http://www.randonneurs.bc.ca/">BC Randonneurs Cycling Club</a>. It's on an annual
release cycle; i.e. I spend the few weeks that pass for winter in
Vancouver updating the project. That's when I bump it to the latest
version of Django, fixing minor bugs, and adding new features that I
and other users have come up with during the preceding year. Once I
release a new version for the new year, I usually don't have to worry
about the code until the next winter. The pony just works,
facilitating people doing <a class="reference external" href="http://www.randonneurs.bc.ca/recbook1/part_sum.html">hundreds of thousands of kilometres</a> of
crazy long cycling events, and we like it that way!</p>
<p>My workflow at the beginning of the annual update looks something
like:</p>
<ul class="simple">
<li>Create a new <tt class="docutils literal">virtualenv</tt></li>
<li>Install the latest version of Django and other project dependencies</li>
<li>Read the release notes for the Django releases since the one I was
working with last</li>
<li>Run the RandoPony test suite to find deprecations and other obvious
breakage</li>
<li>Start hacking</li>
</ul>
<p>I recently started working on the 2012 release of RandoPony and was
blown away when I ran the test suite because there were <em>over 60
failing tests!</em> It took me way longer than it should have to figure
out why things were so massively broken.</p>
<p>The problem was that the test fixtures weren't being installed. They
weren't being installed because they are YAML files and I had
forgotten to install PyYAML in the <tt class="docutils literal">virtualenv</tt>. What's really
annoying is that the fixtures files were being ignored silently.</p>
<p>It turns out that if you specify a YAML fixture for a Django
TestCase:</p>


<div class="pygments_default"><pre><span class="k">class</span> <span class="nc">TestPopulairesListView</span><span class="p">(</span><span class="n">django</span><span class="o">.</span><span class="n">test</span><span class="o">.</span><span class="n">TestCase</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Functional tests for populaires-list view.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">fixtures</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;populaires&#39;</span><span class="p">]</span>
</pre></div>



<p>without giving the fixture file a <tt class="docutils literal">.yaml</tt> extension, the fixture will
be silently ignored if PyYAML isn't installed. Really, Django?!</p>
<p>So, the number 1 thing that I should have done to save myself from
this thrash was to explicitly specify the serialization format of my
fixtures:</p>


<div class="pygments_default"><pre><span class="k">class</span> <span class="nc">TestPopulairesListView</span><span class="p">(</span><span class="n">django</span><span class="o">.</span><span class="n">test</span><span class="o">.</span><span class="n">TestCase</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Functional tests for populaires-list view.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">fixtures</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;populaires.yaml&#39;</span><span class="p">]</span>
</pre></div>



<p>Then the Django test runner would have told me:</p>


<div class="pygments_default"><pre>Problem installing fixture &#39;populaires&#39;: yaml is not a known
serialization format.
</pre></div>



<p>I'll take the hit for ignoring the <a class="reference external" href="http://www.python.org/dev/peps/pep-0020/">PEP 20</a> aphorism &quot;Explicit is
better than implicit&quot;. But shouldn't Django get docked for &quot;Errors
should never pass silently&quot;?</p>
<p>The other thing I should have done was use a <a class="reference external" href="http://www.pip-installer.org/en/latest/requirements.html">pip requirements file</a>
for the project.</p>
<p>RandoPony has 2 requirements files now. <tt class="docutils literal">requirements.txt</tt> for the
packages required for the production deployment, and
<tt class="docutils literal"><span class="pre">requirements-dev.txt</span></tt> for the additional packages, like PyYAML,
required for development work. Now I just have to hope that I'm smart
enough when I start work on the 2013 release to do:</p>


<div class="pygments_default"><pre><span class="o">(</span>randopony<span class="o">)</span><span class="nv">$ </span>pip install -r requirements.txt
<span class="o">(</span>randopony<span class="o">)</span><span class="nv">$ </span>pip install -r requirements-dev.txt
</pre></div>



</div>
]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://douglatornell.ca/blog</uri>
    </author>
    <title type="html"><![CDATA[Stayin' Alive]]></title>
    <link rel="alternate" type="text/html" href="http://douglatornell.ca/blog/2012/01/08/staying-alive" />
    <id>http://douglatornell.ca/blog/2012/01/08/staying-alive</id>
    <updated>2012-01-08T17:05:21Z</updated>
    <published>2012-01-08T17:05:21Z</published>
    <category scheme="http://douglatornell.ca/blog" term="python" />
    <category scheme="http://douglatornell.ca/blog" term="sqlalchemy" />
    <category scheme="http://douglatornell.ca/blog" term="pyramid" />
    <category scheme="http://douglatornell.ca/blog" term="mysql" />
    <summary type="html"><![CDATA[Stayin' Alive]]></summary>
    <content type="html" xml:base="http://douglatornell.ca/blog/2012/01/08/staying-alive"><![CDATA[<div class="document" id="stayin-alive">
<h1 class="title">Stayin' Alive</h1>
<h2 class="subtitle" id="mysql-connection-timeout-and-sqlalchemy-connection-pool-recycling">MySQL Connection Timeout and SQLAlchemy Connection Pool Recycling</h2>
<p>Recently a Pyramid web app surprised me with some odd behaviour. The
app uses SQLAlchemy to interface with a MySQL database. The first
request of the day would always fail with a traceback that ended with
some sort of database connection failure, though not always the same
error. This was happening in the development environment where I was
the only one sending requests to the server. Hitting refresh, or
sending another request resulted in the expected response, and things
would continue to work that way - until the next morning...</p>
<p>The subtitle gives lots of hints about what was going on, so if you're
still reading at this point I'll assume that you're still as puzzled
as I was.</p>
<p>It took a surprising number of tries on Google before I found <a class="reference external" href="http://www.sqlalchemy.org/docs/core/pooling.html?highlight=pool_recycle#setting-pool-recycle">this
section</a> of the SQLAlchemy docs which explains all. To summarize, the
default configuration of MySQL drops connections on which there has
been no activity for 8 hours. SQLAlchemy provides the <tt class="docutils literal">pool_recycle</tt>
parameter for its engine creation functions as a way of working around
that behaviour. (Although, as noted in the <a class="reference external" href="http://www.sqlalchemy.org/docs/core/engines.html?highlight=pool_recycle#engine-creation-api">SQLAlchemy Engine creation
API docs</a> full description of <tt class="docutils literal">pool_recycle</tt>, the behaviour is also
configurable at the MySQLDB connection, and database configuration
levels too.)</p>
<p>Since my Pyramid app uses the <tt class="docutils literal">sqlalchemy.engine_from_config</tt>
function, all I had to do was add:</p>


<div class="pygments_default"><pre><span class="na">sqlalchemy.pool_recycle</span> <span class="o">=</span> <span class="s">3600</span>
</pre></div>



<p>to my <tt class="docutils literal">development.ini</tt> and <tt class="docutils literal">production.ini</tt> config files, and ... problem
solved.</p>
<p>P.S. Sorry - I couldn't resist the <a class="reference external" href="http://www.youtube.com/watch?v=I_izvAbhExY">Bee Gees reference</a> in the
title. It's an age thing...</p>
</div>
]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://douglatornell.ca/blog</uri>
    </author>
    <title type="html"><![CDATA[2012 Python Meme]]></title>
    <link rel="alternate" type="text/html" href="http://douglatornell.ca/blog/2011/12/30/2012-python-meme" />
    <id>http://douglatornell.ca/blog/2011/12/30/2012-python-meme</id>
    <updated>2011-12-30T14:49:46Z</updated>
    <published>2011-12-30T14:49:46Z</published>
    <category scheme="http://douglatornell.ca/blog" term="python" />
    <summary type="html"><![CDATA[2012 Python Meme]]></summary>
    <content type="html" xml:base="http://douglatornell.ca/blog/2011/12/30/2012-python-meme"><![CDATA[<div class="document">
<p>Following <a class="reference external" href="http://tarekziade.wordpress.com/2011/12/20/new-years-python-meme-2/">Tarek Ziade's lead</a>:</p>
<ol class="arabic">
<li><p class="first"><strong>What’s the coolest Python application, framework or library you
have discovered in 2011?</strong></p>
<p>It's a toss-up between <a class="reference external" href="http://docs.pylonsproject.org/en/latest/docs/pyramid.html">Pyramid</a> and <a class="reference external" href="http://docs.python-requests.org/en/latest/index.html">requests</a>.</p>
<p>For the admittedly small, specialized application that I've used
Pyramid for, I like how the framework interface is largely confined
to the <tt class="docutils literal">__init__.py</tt> module. Outside of that I find myself just
writing Python code to get stuff done and throwing in a few
decorators here and there to link into the framework. I find the
Pyramid docs to be really well organized, informative, and
complete. They worked for me at the introductory level (though I
did arrive with quite a bit of experience of other Python web
frameworks) and continue to work as I dig deeper and do more
advanced things.</p>
<p>Requests has made my life so much better in several projects,
whether its collecting data from well structured web services or
scraping hydrometric data from a particularly annoying Government
of Canada site.</p>
</li>
<li><p class="first"><strong>What new programming technique did you learn in 2011?</strong></p>
<p>I got a lot better at writing simple, clean, uncoupled unit tests,
inspired in large part by the <a class="reference external" href="http://docs.pylonsproject.org/en/latest/community/testing.html">Pyramid unit testing guidelines</a>. I
shifted from being a skeptic to a proponent of mocking thanks to
the <a class="reference external" href="http://www.voidspace.org.uk/python/mock/">mock</a> library. I was spurred in that by the need to refactor a
test suite that had become way too slow to be useful.</p>
<p>I also got a lot more proficient in JavaScript, using it for
client-side stuff in web apps, database views for CouchDB, and a
Firefox add-on.</p>
</li>
<li><p class="first"><strong>What’s the name of the open source project you contributed the
most in 2011? What did you do?</strong></p>
<p><a class="reference external" href="http://couchdbkit.org/">CouchDBkit</a>. I spent most of my time at the PyCon 2011 sprints
adding the <tt class="docutils literal">SetProperty</tt> and <tt class="docutils literal">LazySet</tt> class to store Python
sets as lists of unique elements in CouchDB. I also added some
missing Python list methods to the <tt class="docutils literal">LazyList</tt> class. It was a
good learning experience in the realm of subclassing Python
builtins. It was also cool to work sitting beside <a class="reference external" href="http://twitter.com/#!/benoitc">&#64;benoitc</a> (the
CouchDBkit lead developer) in contrast to communicating
electronically across 9 time zones.</p>
</li>
<li><p class="first"><strong>What was the Python blog or website you read the most in 2011?</strong></p>
<p>The <a class="reference external" href="http://planet.python.org/">Planet Python</a> feed, by far.</p>
</li>
<li><p class="first"><strong>What are the three top things you want to learn in 2012?</strong></p>
<ul class="simple">
<li>Message passing systems. I've got a Django project that needs to
get some asynchronicity and I'm planning to explore <a class="reference external" href="http://celeryproject.org/">Celery</a> for
that.</li>
<li>More message passing systems. I've got some devops issues around
server synchronization and failover that I think I might be able
to address with <a class="reference external" href="http://www.zeromq.org/">ZeroMQ</a>.</li>
<li>Python 3. Because it's time! Most of the libraries that I use
have already been ported, so the transition shouldn't be
overwhelmingly difficult, and perhaps I can lend a hand porting
some of the libraries that I need that haven't made the jump yet.</li>
</ul>
</li>
<li><p class="first"><strong>What are the top software, app or lib you wish someone would
write in 2012?</strong></p>
<p>I wish there were more open source libraries and applications in
the home automation realm. One of my first personal Python projects
was a wrapper around <a class="reference external" href="http://www.heyu.org/">heyu</a> to make our house look lived in when we
are away. It's still working okay after nearly 6 years, but the X10
hardware it interfaces with is getting rather long in the
tooth. Sadly, newer home automation hardware and protocols seem to
be mired in the muck of &quot;vendor associations&quot; that only pay lip
service to openness.</p>
</li>
</ol>
<p>Want to do your own list ? here’s how:</p>
<ul class="simple">
<li>copy-paste the questions and answer to them in your blog</li>
<li>tweet it with the <a class="reference external" href="http://twitter.com/#!/search/%232012pythonmeme">#2012pythonmeme</a> hashtag</li>
</ul>
</div>
]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://douglatornell.ca/blog</uri>
    </author>
    <title type="html"><![CDATA[New Blog for Christmas]]></title>
    <link rel="alternate" type="text/html" href="http://douglatornell.ca/blog/2011/12/28/new-blog-for-christmas" />
    <id>http://douglatornell.ca/blog/2011/12/28/new-blog-for-christmas</id>
    <updated>2012-01-02T16:21:32Z</updated>
    <published>2011-12-28T17:19:47Z</published>
    <category scheme="http://douglatornell.ca/blog" term="python" />
    <category scheme="http://douglatornell.ca/blog" term="blog maintenance" />
    <summary type="html"><![CDATA[New Blog for Christmas]]></summary>
    <content type="html" xml:base="http://douglatornell.ca/blog/2011/12/28/new-blog-for-christmas"><![CDATA[<div class="document">
<p>I decided to give myself a new blog for Christmas. All of <a class="reference external" href="http://sadahome.ca/blogs/doug.php">my</a> <a class="reference external" href="http://sadahome.ca/blogs/adventures.php">other</a>
<a class="reference external" href="http://sadahome.ca/blogs/paradocs.php">blogs</a> are based on <a class="reference external" href="http://b2evolution.net">b2evolution</a>. It has served me well for years but
I don't use much of its functionality, and hate dealing with its
comment spam issues so much that I've turned off comments on all of
those blogs. Most of all though, I want to use <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> to
write blog posts, just like I use it to write the vast majority of
other content and docs that I create.</p>
<p><a class="reference external" href="http://blogofile.com">Blogofile</a> caught my eye a while ago, not just because it easy
supports reStructuredText markup, but also because:</p>
<ul class="simple">
<li>it simplifies the blogging workflow to:<ul>
<li>write in your favourite editor</li>
<li>build</li>
<li>upload</li>
</ul>
</li>
<li>it gets rid of the overhead of a blogging app and database backend</li>
<li>it fits nicely into a version control workflow</li>
<li>it encourages delegation of comments, etc. (and the related spam
issues) to <a class="reference external" href="http://disqus.com">Disqus</a></li>
</ul>
<div class="section" id="in-for-a-penny-in-for-a-python-3-pound">
<h1>In for a Penny, in for a Python 3 Pound</h1>
<p>There are <a class="reference external" href="http://blogofile.com/blog/2011/04/30/preview-of-blogofile-0.8/">lots of cool features</a> in the development version of
Blogofile, but running it requires Python 3. That's okay with me
though because with <a class="reference external" href="http://pypi.python.org/pypi?:action=browse&amp;c=533&amp;show=all">all the libraries and frameworks that run under
Python 3 now</a> it's about time I started to use it for something
serious.</p>
<p>A couple of observations:</p>
<ul class="simple">
<li>I still have Python 2.6 set as my default version (for now), so
that's what <a class="reference external" href="http://pypi.python.org/pypi/virtualenv">virtualenv</a> runs under. But <tt class="docutils literal">virtualenv <span class="pre">-p</span> python3
<span class="pre">blogofile-dev</span></tt> happily built a Python 3 virtualenv for me to
install Blogofile and its dependencies in. Is there no end to the
awesome that virtualenv delivers?!</li>
<li>I installed Blogofile with <tt class="docutils literal">python setup.py develop</tt> and noticed
some pauses as the various dependency libraries were being installed
in the virtualenv that were longer than what I'm used to when those
libraries are installed under Python 2. My totally uninformed guess
is that pauses were due to <tt class="docutils literal">2to3</tt> being run in the libraries'
setup.</li>
</ul>
<p>So far I've had no need to touch Python code in the Blogofile
context. It has all been <a class="reference external" href="http://www.makotemplates.org">Mako</a>, HTML5, CSS and reStructuredText so
far. Perhaps when I start to write a converter to migrate old posts
from <a class="reference external" href="http://sadahome.ca/blogs/doug.php">sadahome.ca/blogs/doug.php</a> to here I'll have more to say on the
differences between Python 3 and Python 2.</p>
</div>
<div class="section" id="a-whole-new-site-actually">
<h1>A Whole New Site, Actually</h1>
<p>Blogofile is more than a blogging tool though; it's a static site
builder. So, I took the opportunity to add some structure and style to
the whole <tt class="docutils literal">douglatornell.ca</tt> site. Migrating the content was easy,
largely because it was already all in reStructuredText markup. The
biggest time-sink was my attempt to create a new theme with a
different colour scheme. Once again I was reminded at how badly I suck
at the design aspect of web development. I settled for changing the
title font to something that looks less like Comic Sans.</p>
</div>
<div class="section" id="things-that-still-need-to-be-done">
<h1>Things That Still Need to be Done</h1>
<p><em>Updated 2011-12-29 20:52:51</em></p>
<ul class="simple">
<li><span class="strikethrough">Automate the process of pushing new content to
Webfaction (affiliate link), either via a Mercurial hook, or a
Fabric task, in contrast to the manual rsync command I'm using now</span>
Getting a <a class="reference external" href="https://groups.google.com/forum/#!topic/blogofile-discuss/4D-UKzZVIY4">Mercurial hook</a> working turned out to be pretty easy.</li>
</ul>
<p><em>Updated 2012-01-02 16:21:32</em></p>
<ul class="simple">
<li><span class="strikethrough">Use Disqus for comments</span> Incredibly easy!</li>
<li>Migrate at least the Python-related content from sadahome.ca/blogs/doug.php</li>
<li>Convert the <a class="reference external" href="http://pypi.python.org/pypi/nosy">Nosy</a> docs to <a class="reference external" href="http://sphinx.pocoo.org/">Sphinx</a> and move them to <a class="reference external" href="http://readthedocs.org/">Read the Docs</a></li>
</ul>
<p><em>Updated 2012-01-02 10:18:37</em></p>
<ul class="simple">
<li><span class="strikethrough">Add a Flickr badge to display a selection of my
images in the sidebar</span> Done, though the <a class="reference external" href="http://www.flickr.com/badge.gne">Flickr badge</a> markup is
pretty old and crufty looking, so I may revisit this to try to do
something more modern using <a class="reference external" href="http://jquery.com/">jQuery</a>.</li>
</ul>
</div>
</div>
]]></content>
  </entry>
</feed>

