<?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>eriksmartt.com/blog &#187; python</title>
	<atom:link href="http://www.eriksmartt.com/blog/archives/tag/python/feed" rel="self" type="application/rss+xml" />
	<link>http://www.eriksmartt.com/blog</link>
	<description>my little chunk of bandwidth</description>
	<lastBuildDate>Thu, 30 Jun 2011 15:17:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19854</generator>
		<item>
		<title>jsmacro 0.2.3</title>
		<link>http://www.eriksmartt.com/blog/archives/1274</link>
		<comments>http://www.eriksmartt.com/blog/archives/1274#comments</comments>
		<pubDate>Sat, 20 Feb 2010 02:02:29 +0000</pubDate>
		<dc:creator>erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jsmacro]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.eriksmartt.com/blog/?p=1274</guid>
		<description><![CDATA[The latest jsmacro (v0.2.3) adds support for &#8220;else&#8221; clauses to &#8220;if&#8221;, &#8220;ifdef&#8221;, and &#8220;ifndef&#8221; statements. Combine this with the command-line variable definition support and you can now do fun things like this: //@ifdef IE6_BUILD ...custom IE6 code here //@else ...code for other browsers here //@end Of course, this goes against the idea that your JavaScript [...]]]></description>
			<content:encoded><![CDATA[<p>The latest <a href="http://github.com/smartt/jsmacro">jsmacro</a> (v0.2.3) adds support for &#8220;else&#8221; clauses to &#8220;if&#8221;, &#8220;ifdef&#8221;, and &#8220;ifndef&#8221; statements.  Combine this with the command-line variable definition support and you can now do fun things like this:</p>
<pre><code>
//@ifdef IE6_BUILD
 ...custom IE6 code here
//@else
 ...code for other browsers here
//@end
</code></pre>
<p>Of course, this goes against the idea that your JavaScript would remain usable for development without needing to be processed, but it&#8217;s just an example.  Longer term, I hope to have a different approach available that will allow conditional code substitution so that browser specific optimizations won&#8217;t get in the way of an easy development/test/debug process.</p>]]></content:encoded>
			<wfw:commentRss>http://www.eriksmartt.com/blog/archives/1274/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jsmacro &#8212; an oddly named JavaScript preprocessor</title>
		<link>http://www.eriksmartt.com/blog/archives/1254</link>
		<comments>http://www.eriksmartt.com/blog/archives/1254#comments</comments>
		<pubDate>Tue, 26 Jan 2010 01:38:55 +0000</pubDate>
		<dc:creator>erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jsmacro]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.eriksmartt.com/blog/?p=1254</guid>
		<description><![CDATA[For awhile now I&#8217;ve wanted a JavaScript preprocessor to conditionally include debug and testing code when needed. It&#8217;s always registered as merely a &#8220;nice to have&#8221;, so I hadn&#8217;t sought one out. However, I had a little time over the weekend and wanted to play with the idea, so here it is: jsmacro (on GitHub.) [...]]]></description>
			<content:encoded><![CDATA[<p>For awhile now I&#8217;ve wanted a JavaScript preprocessor to conditionally include debug and testing code when needed.  It&#8217;s always registered as merely a &#8220;nice to have&#8221;, so I hadn&#8217;t sought one out.  However, I had a little time over the weekend and wanted to play with the idea, so here it is: <a href="http://github.com/smartt/jsmacro">jsmacro</a> (on GitHub.)</p>
<p>[Note that before writing this I did seek out existing implementations, and found <a href="http://www.bramstein.com/projects/preprocess/">js-preprocess</a> to be the most interesting; However, I needed something that would work as part of an existing build chain, so authoring the tool in Python instead of JavaScript made more sense.]</p>
<p>Currently, jsmacro is poorly named, as I didn&#8217;t write the macro system that was in my head.  Instead, it&#8217;s currently a basic preprocessor supporting only DEFINE and IF statements, which happened to be all I needed at the time.  Usage works like this:</p>
<h3>Input JavaScript</h3>
<pre><code>
  //@define DEBUG 0

  var foo = function() {
    //@if DEBUG
    alert('This.');
    alert('That.');
    //@end

    print "Hi";
  };
</code></pre>
<p>Pass the above JavaScript through jsmacro from the command line like this: <code>./jsmacro.py -f infile.js &gt; outfile.js</code> (assuming the files are all in the same directory), and you get the following:</p>
<h3>Output JavaScript</h3>
<pre><code>
  var foo = function() {

    print "Hi";
  };
</code></pre>
<p>The tool has registered the variable &#8216;DEBUG&#8217;as 0 (i.e., false), so the conditional include statements omit the alert() calls.  If DEBUG had been set to 1 (i.e., true), the alert() statements would remain (though all jsmacro instructions would be removed either way.)</p>
<p>One of the tricky things about doing macros or preprocessing in JavaScript is that I wanted the code to be valid JavaScript before the tool is run (which is why C-preprocessors won&#8217;t work.)  The idea is that you develop as you normally would, but wrap your debug and testing code in conditional jsmacro statements so that they are automatically removed as part of your build process.</p>
<p>There&#8217;s nothing fancy about the current implementation (it&#8217;s a crude state machine that scans line-by-line, top-to-bottom looking for regex patterns and deciding whether to output the line of not.)  Crude as it may be though, it completely solved a problem for me, and hopefully it will help you out as well.</p>]]></content:encoded>
			<wfw:commentRss>http://www.eriksmartt.com/blog/archives/1254/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Announcing tinyLinkFeed &#8212; RSS feeds for links posted to Twitter</title>
		<link>http://www.eriksmartt.com/blog/archives/1000</link>
		<comments>http://www.eriksmartt.com/blog/archives/1000#comments</comments>
		<pubDate>Thu, 06 Aug 2009 03:47:37 +0000</pubDate>
		<dc:creator>erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tinylinkfeed]]></category>

		<guid isPermaLink="false">http://www.eriksmartt.com/blog/?p=1000</guid>
		<description><![CDATA[I&#8217;ve come to enjoy the link-sharing that happens on Twitter, but a few months back I found myself with less time to regularly scan my Twitter stream. Since I don&#8217;t always need real-time links, devising a mechanism to time-shift, and read at my leisure, seemed appropriate. Furthermore, since I don&#8217;t mind following friend&#8217;s del.icio.us feeds [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve come to enjoy the link-sharing that happens on <a href="http://twitter.com">Twitter</a>, but a few months back I found myself with less time to regularly scan my Twitter stream.</p>
<p>Since I don&#8217;t always need real-time links, devising a mechanism to time-shift, and read at my leisure, seemed appropriate.  Furthermore, since I don&#8217;t mind following friend&#8217;s <a href="http://delicious.com/">del.icio.us</a> feeds with a feed reader, converting tweets-with-links into RSS feeds seemed like a natural fit.  After some brainstorming with <a href="http://twitter.com/karllong">@karllong</a> and a bit of hacking, <a href="http://www.tinylinkfeed.com/">tinyLinkFeed</a> was born!</p>
<p><img src="http://www.eriksmartt.com/blog/wp-content/uploads/2009/08/tinylinkfeed_screenshot.jpg" width="350" height="295" /></p>
<p>tinyLinkFeed is designed to aggregate microblogging streams (like Twitter), and expose RSS feeds for posts containing URLs.  To make the feeds a bit more useful, tinyLinkFeed also resolves shortened URLs, so you know what you&#8217;re linking to.  (The URL un-shortening is done by another webservice I wrote at the same time, called <a href="http://tinyexpander.appspot.com/">tinyexpander</a>; but I&#8217;ll save those details for another post.)</p>
<p>Using tinyLinkFeed is pretty straight-forward.  For example, my normal Twitter page can be found at <a href="http://twitter.com/smartt">http://twitter.com/smartt</a>, so my tinyLinkFeed page lives at <a href="http://www.tinylinkfeed.com/twitter/smartt">http://www.tinylinkfeed.com/twitter/smartt</a>.  To follow the links I post to Twitter, you&#8217;d point your RSS reader to <a href="http://www.tinylinkfeed.com/feed/twitter/smartt.xml">http://www.tinylinkfeed.com/feed/twitter/smartt.xml</a>.  For something perhaps more useful, you might try Tim O&#8217;Reilly&#8217;s link feed: <a href="http://www.tinylinkfeed.com/feed/twitter/timoreilly.xml">http://www.tinylinkfeed.com/feed/twitter/timoreilly.xml</a> (which is actually one of the main reasons I wrote tinyLinkFeed.)</p>
<p>The application came together fairly quick (it&#8217;s written in <a href="http://python.org">Python</a> and runs on <a href="http://code.google.com/appengine/">Google App Engine</a>), though I haven&#8217;t had time to expand it since launch.  I have a few ideas on what to add next, but I&#8217;m setting up getSatisfaction so you can leave ideas as well.</p>
<p>Adding profiles to tinyLinkFeed&#8217;s aggregator isn&#8217;t openly available yet, so if you&#8217;d like a profile added, drop a message to <a href="http://twitter.com/smartt">@smartt</a> or <a href="http://twitter.com/tinylinkfeed">@tinylinkfeed</a>.  I hope you find it useful!</p>]]></content:encoded>
			<wfw:commentRss>http://www.eriksmartt.com/blog/archives/1000/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How-To: Dynamic WWW-Authentication (.htaccess style) on Google App Engine</title>
		<link>http://www.eriksmartt.com/blog/archives/882</link>
		<comments>http://www.eriksmartt.com/blog/archives/882#comments</comments>
		<pubDate>Sat, 16 May 2009 23:15:13 +0000</pubDate>
		<dc:creator>erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.eriksmartt.com/blog/?p=882</guid>
		<description><![CDATA[Sometimes classic Basic Access Authentication is the right approach to password protecting a webpage. It&#8217;s not secure from sniffing, but functional if you&#8217;re just trying to ward off the casual surfer in the wrong spot. (For example, restricting access to your cat pictures, not your missile silo codes.) Basic authentication is often added to sites [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes classic <a href="http://en.wikipedia.org/wiki/Basic_access_authentication">Basic Access Authentication</a> is the right approach to password protecting a webpage.  It&#8217;s not secure from sniffing, but functional if you&#8217;re just trying to ward off the casual surfer in the wrong spot.  (For example, restricting access to your cat pictures, not your missile silo codes.)</p>
<p>Basic authentication is often added to sites (or directories) using a .htaccess file and something like this:</p>
<p><code>
<pre>
AuthUserFile /home/foo/.htpasswd
AuthName "Private Area"
AuthType Basic

&lt;Limit GET&gt;
require valid-user
&lt;/Limit&gt;
</pre>
<p></code></p>
<p>&#8230;but you can also do basic authentication on-the-fly by reading/writing HTTP Headers.  To ask the browser for a user/password, you can raise a 401 error, and write a &#8220;www-Authenticate&#8221; header containing something like &#8216;Basic realm=&#8221;Secure Area&#8221;&#8216;.  To read the user/password, look for an Authorization header, grab it&#8217;s value, Base 64 decode it, and you should have a string in the form of &#8220;user:password&#8221;.</p>
<p>Here&#8217;s how you might handle it with Google App Engine.  (Well, really you might use a decorator.. but this example is easier to explain.)</p>
<p><code>
<pre>
class AuthTest(webapp.RequestHandler):
  def get(self):

    # Wrapping in a huge try/except isn't the best approach. This is just
    # an example for how you might do this.
    try:
      # Parse the header to extract a user/password combo.
      # We're expecting something like "Basic XZxgZRTpbjpvcGVuIHYlc4FkZQ=="
      auth_header = self.request.headers['Authorization']

      # Isolate the encoded user/passwd and decode it
      auth_parts = auth_header.split(' ')
      user_pass_parts = base64.b64decode(auth_parts[1]).split(':')
      user_arg = user_pass_parts[0]
      pass_arg = user_pass_parts[1]

      checkAuth(user_arg, pass_arg) # have this call raise an exception if it fails

      self.response.out.write(template.render('templates/foo.html', {}))

    except Exception, e:
      logging.debug("AuthTest Exception: %s" % (e))

      # Here's how you set the headers requesting the browser to prompt
      # for a user/password:
      self.response.set_status(401, message="Authorization Required")
      self.response.headers['WWW-Authenticate'] = 'Basic realm="Secure Area"'

      # Rendering a 401 Error page is a good way to go...
      self.response.out.write(template.render('templates/error/401.html', {}))
</pre>
<p></code></p>
<p>That&#8217;s all there is to it.</p>
<p>If you want to programatically write an Authorization header (as in, sending authentication credentials to another site, like the Twitter API&#8217;s, for example) you&#8217;ll do something like this:</p>
<p><code>
<pre>
request = urllib2.Request(url)
request.add_header('Authorization', "Basic %s" % (base64.b64encode("%s:%s" % (user, password))))
</pre>
<p></code></p>
<p>Enjoy!</p>]]></content:encoded>
			<wfw:commentRss>http://www.eriksmartt.com/blog/archives/882/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Conway&#8217;s Game of Life in Nodebox</title>
		<link>http://www.eriksmartt.com/blog/archives/771</link>
		<comments>http://www.eriksmartt.com/blog/archives/771#comments</comments>
		<pubDate>Wed, 25 Feb 2009 17:31:05 +0000</pubDate>
		<dc:creator>erik</dc:creator>
				<category><![CDATA[art]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.eriksmartt.com/blog/?p=771</guid>
		<description><![CDATA[I was reading Ben Fry&#8216;s thesis, Organic Information Design yesterday, came across the section on Conway&#8217;s Game of Life, and thought it would make a nice NodeBox demo. Here it is: conway-life.py There&#8217;s not much to it, but it does show a software pattern I&#8217;ve been using frequently with NodeBox. Many of the NodeBox examples [...]]]></description>
			<content:encoded><![CDATA[<p>I was reading <a href="http://benfry.com/">Ben Fry</a>&#8216;s thesis, <a href="http://benfry.com/organic/">Organic Information Design</a> yesterday, came across the section on <a href="http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life">Conway&#8217;s Game of Life</a>, and thought it would make a nice <a href="http://nodebox.net/">NodeBox</a> demo.</p>
<p>Here it is: <a href="http://www.eriksmartt.com/blog/wp-content/uploads/2009/02/conway-life.py">conway-life.py</a></p>
<p><img src="http://www.eriksmartt.com/blog/wp-content/uploads/2009/02/conway-in-nodebox.jpg" width="500"  alt="Nodebox screenshot" /><br />
<br clear="all" /></p>
<p>There&#8217;s not much to it, but it does show a software pattern I&#8217;ve been using frequently with NodeBox.  Many of the NodeBox examples make heavy use of non-namespaced, global variables.  I suppose it makes simple code easy to read for those new to programming, but it&#8217;s a habit you&#8217;ll want to break before your code starts getting more complex.</p>
<p>What I&#8217;ve found helpful is to create a World/Universe/Controller/Stage object that drives the rendering.  Instead of using multiple globals in <code>draw()</code>, the controller object keeps the main parameters as local properties, and instantiates any needed objects in it&#8217;s <code>__init__()</code>.  This approach prevents global variables names from clashing, and allows for creative reuse of rendering components.</p>
<p>Enjoy!</p>]]></content:encoded>
			<wfw:commentRss>http://www.eriksmartt.com/blog/archives/771/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using pymunk (physics engine) in NodeBox</title>
		<link>http://www.eriksmartt.com/blog/archives/747</link>
		<comments>http://www.eriksmartt.com/blog/archives/747#comments</comments>
		<pubDate>Mon, 23 Feb 2009 16:32:37 +0000</pubDate>
		<dc:creator>erik</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.eriksmartt.com/blog/?p=747</guid>
		<description><![CDATA[NodeBox makes a great environment for data visualizations and generative art. It&#8217;s easy to get started in, and you get basic drawing, type, and image manipulation. When you&#8217;re ready for more, it&#8217;s not too difficult to bring in external Python libraries to connect NodeBox to other systems, or add physics and particle simulation to spice [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://nodebox.net/">NodeBox</a> makes a great environment for data visualizations and generative art.  It&#8217;s easy to get started in, and you get basic drawing, type, and image manipulation.  When you&#8217;re ready for more, it&#8217;s not too difficult to bring in external Python libraries to connect NodeBox to other systems, or add physics and particle simulation to spice up your visuals.</p>
<p>For those unfamiliar with NodeBox,</p>
<blockquote><p>&#8220;NodeBox is a Mac OS X application that lets you create 2D visuals (static, animated or interactive) using Python programming code and export them as a PDF or a QuickTime movie.&#8221;</p></blockquote>
<p>It uses <a href="http://pyobjc.sourceforge.net/">PyObjC</a> to embed a <a href="http://python.org/">Python</a> runtime into an OS X native application, and fits into the same toolbox as <a href="http://processing.org/">Processing</a> and <a href="http://openframeworks.cc/">openFrameworks</a>.  It&#8217;s a bit slower to run complex animations in, but you&#8217;re coding in Python, you get the gorgeous fonts and anti-aliasing you&#8217;d expect on OS X, and it provides easy access to some OS X native libraries, like Core Image.  For a quick look at what it can do, check out the <a href="http://nodebox.net/code/index.php/Gallery">NodeBox gallery</a>.</p>
<p>NodeBox includes it&#8217;s own Python build, which is nice for portability and reliability, but it uses a custom <code>sys.path</code> that doesn&#8217;t look for Python packages you might already have installed on your system.  There are a few ways to deal with this:</p>
<ol>
<li>You can install your packages into NodeBox&#8217;s path, ie., <code>~/Library/Application\ Support/NodeBox/</code> &#8212; meaning that you can use them from NodeBox, but not from other scripts&#8230;</li>
<li>You can <code>import sys</code> in your NodeBox code and manually modify the <code>sys.path</code> value to add your existing packages&#8230;</li>
<li>You can install packages into your system site-packages directory, and sym-link them from NodeBox&#8217;s directory&#8230;</li>
<li>You can make NodeBox use your system packages instead of it&#8217;s own by sym-linking <code>~/Library/Application\ Support/NodeBox</code> to your site-packages directory of choice (ex., <code>/Library/Python/2.5/site-packages</code>)</li>
</ol>
<p>For this exercise, I&#8217;ll be adding <a href="http://code.google.com/p/pymunk/">pymunk</a> (Python bindings for the <a href="http://wiki.slembcke.net/main/published/Chipmunk">Chipmonk</a> physics library) to NodeBox using option #3: Installing pymunk globally, and sym-linking from NodeBox&#8217;s package directory.  This allows me to run the pymunk examples from the command-line (which use PyGame and Pyglet), but still use pymunk from NodeBox.  This may not always be the best solution, so you&#8217;ll have to pick what&#8217;s right for your needs.</p>
<p>Let&#8217;s get started.</p>
<p>Pymunk (at the time of writing) includes it&#8217;s own copy of the Chipmunk source code, making this whole process rather easy.  Once you&#8217;ve downloaded and uncompressed the pymunk source, <code>cd</code> into it&#8217;s directory and build chipmunk using:</p>
<p><code>&gt; python setup.py build_chipmunk</code></p>
<p>Now you can build and install pymunk:</p>
<p><code>&gt; python setup.py install</code></p>
<p>This will install an egg (which I normally hate dealing with, but that&#8217;s another story.)  If you don&#8217;t want the egg, just copy the <code>pymunk</code> directory into your site-packages.</p>
<p>Now we&#8217;ll add pymunk to NodeBox&#8217;s path.  My pymunk is in <code>/Library/Python/2.5/site-packages/</code>, so I&#8217;ll:</p>
<p><code>&gt; cd ~/Library/Application\ Support/NodeBox</code></p>
<p><code>&gt; ln -s /Library/Python/2.5/site-packages/pymunk-0.8.1-py2.5.egg/pymunk .</code></p>
<p>Finally, NodeBox needs access to libchipmunk.  I used this approach:</p>
<p><code>&gt; cd /Applications/NodeBox/NodeBox.app/Contents/MacOS/</code></p>
<p><code>&gt; ln -s ~/Library/Application\ Support/NodeBox/pymunk/libchipmunk.dylib .</code></p>
<p>We should be done!  Fire up NodeBox and try an <code>include pymunk</code> to see if it loads.  If you don&#8217;t see any error messages, you&#8217;re good to go.</p>
<p>If you&#8217;re new to pymunk (as I was until this week), head over to the <a href="http://code.google.com/p/pymunk/wiki/SlideAndPinJointsExample">Slide and Pin Joint tutorial</a> to see how it works.  The example is written for <a href="http://pygame.org/">PyGame</a>, so you&#8217;ll be doing a little rewriting to bring it into NodeBox.</p>
<p>The following screenshot shows the Slide and Pin Joint demo within NodeBox using my take on porting it.  I&#8217;m having a little trouble with the slide joint, but you can check out my code if you&#8217;re curious: <a href="http://www.eriksmartt.com/blog/wp-content/uploads/2009/02/slide_and_pinjoint_example.py">slide_and_pinjoint_example.py</a></p>
<p><img src="http://www.eriksmartt.com/blog/wp-content/uploads/2009/02/pymunk_in_nodebox.jpg" width="550"  border="0" alt="pymunk in nodebox screenshot" /><br />
<br clear="all" /></p>]]></content:encoded>
			<wfw:commentRss>http://www.eriksmartt.com/blog/archives/747/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Presenting at Austin Python User Group tomorrow (9/10) 7pm</title>
		<link>http://www.eriksmartt.com/blog/archives/562</link>
		<comments>http://www.eriksmartt.com/blog/archives/562#comments</comments>
		<pubDate>Tue, 09 Sep 2008 22:54:19 +0000</pubDate>
		<dc:creator>erik</dc:creator>
				<category><![CDATA[austin]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.eriksmartt.com/blog/?p=562</guid>
		<description><![CDATA[FYI, some colleagues and I will be presenting at the Austin Python User Group (APUG) meeting tomorrow night (Wednesday, September 10th) at 7pm. We&#8217;ll be talking &#8220;behind-the-scenes tech&#8221; for one of the high-traffic, Django-based sites we&#8217;ve been building over the past year. For directions and more info, see the APUG wiki: http://wiki.python.org/moin/AustinPythonUserGroup Hope to see [...]]]></description>
			<content:encoded><![CDATA[<p>FYI, some colleagues and I will be presenting at the Austin Python User Group (APUG) meeting tomorrow night (Wednesday, September 10th) at 7pm.  We&#8217;ll be talking &#8220;behind-the-scenes tech&#8221; for one of the high-traffic, <a href="http://djangoproject.com">Django</a>-based sites we&#8217;ve been building over the past year.</p>
<p>For directions and more info, see the APUG wiki: <a href="http://wiki.python.org/moin/AustinPythonUserGroup">http://wiki.python.org/moin/AustinPythonUserGroup</a></p>
<p>Hope to see you there!</p>]]></content:encoded>
			<wfw:commentRss>http://www.eriksmartt.com/blog/archives/562/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Book Review: &#8220;Practical Django Projects&#8221;</title>
		<link>http://www.eriksmartt.com/blog/archives/506</link>
		<comments>http://www.eriksmartt.com/blog/archives/506#comments</comments>
		<pubDate>Tue, 22 Jul 2008 02:08:23 +0000</pubDate>
		<dc:creator>erik</dc:creator>
				<category><![CDATA[books]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.eriksmartt.com/blog/?p=506</guid>
		<description><![CDATA[Summary: Targeted at developers wanting to learn Django by building example applications rather then (or in addition to) reading the docs and man pages The reader builds three working applications by following along The examples are based on up-to-date Django features (ie., a 2008 build) Lesson&#8217;s focused on using Django (not on Django&#8217;s inner workings) [...]]]></description>
			<content:encoded><![CDATA[<h3>Summary:</h3>
<ul>
<li>Targeted at developers wanting to learn Django by building example applications rather then (or in addition to) reading the docs and man pages</li>
<li>The reader builds three working applications by following along</li>
<li>The examples are based on up-to-date Django features (ie., a 2008 build)</li>
<li>Lesson&#8217;s focused on using Django (not on Django&#8217;s inner workings)</li>
<li>Doesn&#8217;t waste time explaining Python and HTML (nor does it dive deep explaining the how/why of what you&#8217;re doing in the examples)</li>
<li>Introduces the reader to powerful Django features &#8212; covering a wide range of capability</li>
<li>Examples focus on designing for code reuse (and leading by example, by integrating with existing reusable apps and Python libraries)</li>
<li>Offers an alternative approach to learning, focused on relevant, practical examples</li>
</ul>
<h3>Background:</h3>
<p><a href="http://www.amazon.com/gp/product/1590599969?ie=UTF8&#038;tag=eriksmarttcom&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1590599969">Practical Django Projects</a><img src="http://www.assoc-amazon.com/e/ir?t=eriksmarttcom&#038;l=as2&#038;o=1&#038;a=1590599969" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> (<a href="http://www.apress.com/book/view/1590599969">Apress book description</a>) was written by <a href="http://www.b-list.org/">James Bennett</a>, release manager and contributor to the <a href="http://djangoproject.com/">Django</a> Web Framework. It was published by <a href="http://www.apress.com/">Apress</a> in 2008.  This was Bennett&#8217;s first book.</p>
<p>Full disclosure: I was provided with a free, review-copy of the book by Apress.</p>
<h3>The Book:</h3>
<p>Practical Django Projects introduces the reader to the Django Web Framework by example.  It takes the reader step-by-step through three example projects: a basic CMS, a blog application (called <a href="http://code.google.com/p/coltrane-blog/">Coltrane</a>, which powers the author&#8217;s personal blog), and a code-sharing/snippets site (called <a href="http://code.google.com/p/cab/">Cab</a>, which powers <a href="http://www.djangosnippets.org/">http://www.djangosnippets.org/</a>.)  The examples cover real-world problems (and integration tasks) that developers are likely to be interested in, and leaves the reader with three working Django applications.</p>
<p>The lessons are spread across eleven chapters:</p>
<ol>
<li><b>Welcome to Django</b> &#8212; a wonderfully short introduction that wastes no space explaining prerequisites (it assumes the reader knows Python)</li>
<li><b>Your First Django Site: A Simple CMS</b> &#8212; an introduction to the Django Admin and <a href="http://www.djangoproject.com/documentation/flatpages/">Flatpages</a></li>
<li><b>Customizing the Simple CMS</b> &#8212; customizing the Admin interface (adding <a href="http://tinymce.moxiecode.com/">TinyMCE</a>) and developing a simple, reusable search feature</li>
<li><b>A Django-Powered Weblog</b> &#8212; defining the basic models, and using <a href="http://code.google.com/p/django-tagging/">django-tagging</a> and <a href="http://www.djangoproject.com/documentation/generic_views/">Generic Views</a></li>
<li><b>Expanding the Weblog</b> &#8212; adding <a href="http://del.icio.us/">del.icio.us</a>-synced links, and custom categories</li>
<li><b>Templates for the Weblog</b> &#8212; more extensive use of Generic Views, template inheritance, and custom template tags</li>
<li><b>Finishing the Weblog</b> &#8212; using <a href="http://www.djangoproject.com/documentation/add_ons/">django.contrib</a>.comments and model signals to develop a moderation system with email notification and <a href="http://akismet.com/">Akismet</a> integration; Using <a href="http://www.djangoproject.com/documentation/syndication_feeds/">django.contrib.syndication</a> to add RSS/Atom feeds</li>
<li><b>A Social Code-Sharing Site</b> &#8212; building the initial models, integrating with the <a href="http://pygments.org/">pygments</a> syntax highlighter, and writing custom model managers</li>
<li><b>Form Processing in the Code-Sharing Application</b> &#8212; great examples of using <a href="http://www.djangoproject.com/documentation/newforms/">newforms</a> (much better then the <a href="http://www.amazon.com/gp/product/1590597257?ie=UTF8&#038;tag=eriksmarttcom&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1590597257">The Definitive Guide to Django</a><img src="http://www.assoc-amazon.com/e/ir?t=eriksmarttcom&#038;l=as2&#038;o=1&#038;a=1590597257" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />&#8216;s chapter on form processing)</li>
<li><b>Finishing the Code-Sharing Application</b> &#8212; more custom template tags, this time used with bookmarking and rating features</li>
<li><b>Writing Reusable Django Applications</b> &#8212; a summary of Bennett&#8217;s philosophy on decoupling application features into reusable components (with references to the UNIX saying, &#8220;do one thing, and do it well&#8221;)</li>
</ol>
<p>The examples focus on building applications the &#8220;Django way&#8221; &#8212; meaning that they heavily leverage Django features such as Generic Views, custom template tags, and the django.contrib package.  Each section starts by outlining the features to be developed, then walking the reader through model definitions, URLs, template design, and the request-handler (view) code.</p>
<p>While working through the three example applications, Bennett teaches the reader how to decouple applications from projects, how to think about (and look for) opportunities for code reuse, and how to integrate with other reusable Django applications.  The lessons aren&#8217;t so much &#8220;how does Django work&#8221;, but rather &#8220;how do you, as a developer, structure your projects to get the most out of the framework.&#8221;  Depending on your level of comfort using Django and Python, the lessons will either be a breeze, or ridiculously confusing.  (ie., there&#8217;s a lot of magic going on in the examples, and the book assumes that either you get it, you&#8217;re comfortable not knowing, or that you&#8217;ll figure out the finer bits when you need them.)</p>
<h4>The Core Message</h4>
<p>Ultimately, the book isn&#8217;t so much about learning Django, as it is about learning how to use Django properly (where properly is defined as the way in which the Django developers use Django.)  From this perspective, it&#8217;s quite successful.  The reader is shown a number of patterns and concepts that can be applied to any Django project.</p>
<p>Bennett wraps up the book with a chapter on design philosophy, but I think the overall lesson of the book is best summarized on page 124, with the following quote:</p>
<blockquote><p>
&#8230;this is the hallmark of a well-built Django application.  Installing it shouldn&#8217;t involve any more work than the following:</p>
<ol>
<li>Add it to <code>INSTALLED_APPS</code> and run <code>syncdb</code>.</li>
<li>Add a new URL pattern to route to its default URLConf.</li>
<li>Set up any needed templates.</li>
</ol>
</blockquote>
<p>This is the zen of pluggable Django applications.  It&#8217;s the path Bennett wants to help you start down.  The value of going down this path will depend on how often you&#8217;ll use Django in the future.</p>
<h3>Conclusion:</h3>
<p>Overall, I think the book will be more valuable for someone just getting started with Django, then someone who&#8217;s been hacking lower-level with the framework for awhile.  It&#8217;s a developer-focused, quick-start, &#8220;get you on the right foot&#8221; kind of book that I certainly would have appreciated more a few years ago.  The big question then, is whether this book is for you.  The answer depends on a couple things, with the most important being how you like to learn.  Do you prefer learning by example, or learning by reading the docs and building things on your own? <b>If you prefer to have an expert guide you step-by-step, then this book is for you.</b>  You&#8217;ll still need to poke around in the <a href="http://www.djangoproject.com/documentation/">Django documentation</a> to really grok how it all works, but this book will get you up to speed quickly.</p>
<p>If you&#8217;ve read the docs, done the online tutorials, and are still interested in picking up some best-practices on decoupling your code from your specific application (ie., learning how Django supports code reuse), then this may still be a book for you.  If you know you&#8217;ll be building a large application, the lessons in the book <b>might help prevent you from writing a single, monolithic application</b>, or at least give you some insight into how to organize and package your code.  Down the road you&#8217;ll thank yourself.</p>
<p>For me personally, I was actually looking forward to this book before it came out.  I think the Django docs online (as great as they are) can sometimes lack in providing best practices.  However, I&#8217;ve also been using the framework professionally for a number of years (to deploy personal, start-up, and enterprise-class web applications), and I&#8217;ve previously built and deployed a pluggable, multi-site, Django-based blog engine (with del.icio.us and Akismet integration, flexible moderation rules, etc.), so the idea of using a blog engine as the core example in the book was a bit disappointing.  That said, I did enjoy seeing another developer&#8217;s approach on solving the same problem, and I picked up a few nice tips around some of the more recent Django features.</p>
<p>If you&#8217;re looking to build a reusable code library (and you should be, if you&#8217;re going to build more then one Django project) and ensure that you&#8217;re using Django efficiently, this book will help point you down the right path and have you thinking about decoupling your architecture from the start.</p>]]></content:encoded>
			<wfw:commentRss>http://www.eriksmartt.com/blog/archives/506/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Austin Python Users Group meeting tomorrow (May 14th) with guest speaker Greg Wilson</title>
		<link>http://www.eriksmartt.com/blog/archives/443</link>
		<comments>http://www.eriksmartt.com/blog/archives/443#comments</comments>
		<pubDate>Tue, 13 May 2008 14:35:57 +0000</pubDate>
		<dc:creator>erik</dc:creator>
				<category><![CDATA[austin]]></category>
		<category><![CDATA[for:optaros]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.eriksmartt.com/blog/?p=443</guid>
		<description><![CDATA[This month&#8217;s APUG meeting will feature guest speaker Greg Wilson, author of Beautiful Code, Data Crunching, Parallel Programming Using C++, Practical Parallel Programming, etc. For more details, see: http://wiki.python.org/moin/AustinPythonUserGroup and http://python.meetup.com/188/. Hope to see you there!]]></description>
			<content:encoded><![CDATA[<p>This month&#8217;s APUG meeting will feature guest speaker <a href="http://pyre.third-bit.com/blog/greg-wilson">Greg Wilson</a>, author of Beautiful Code, Data Crunching, Parallel Programming Using C++, Practical Parallel Programming, etc.</p>
<p>For more details, see: <a href="http://wiki.python.org/moin/AustinPythonUserGroup">http://wiki.python.org/moin/AustinPythonUserGroup</a> and <a href="http://python.meetup.com/188/">http://python.meetup.com/188/</a>.</p>
<p>Hope to see you there!</p>]]></content:encoded>
			<wfw:commentRss>http://www.eriksmartt.com/blog/archives/443/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading &#8220;The Definitive Guide to Django&#8221;; Verdict: A solid learning reference for a beginning/intermediate Django user</title>
		<link>http://www.eriksmartt.com/blog/archives/411</link>
		<comments>http://www.eriksmartt.com/blog/archives/411#comments</comments>
		<pubDate>Tue, 01 Jan 2008 01:07:50 +0000</pubDate>
		<dc:creator>erik</dc:creator>
				<category><![CDATA[books]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.eriksmartt.com/blog/archives/411</guid>
		<description><![CDATA[Last week I received a review-copy of the new &#8220;The Definitive Guide to Django&#8221; book from Apress. I hadn&#8217;t planned on buying the book since it seemed a little too beginner-focused; but I agreed to give it an honest reading, so I happily dove in with an &#8220;it&#8217;s Python, of course I&#8217;m going to like [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I received a review-copy of the new &#8220;<a href="http://www.djangobook.com/">The Definitive Guide to Django</a>&#8221; book from <a href="http://www.apress.com/">Apress</a>.  I hadn&#8217;t planned on buying the book since it seemed a little too beginner-focused; but I agreed to give it an honest reading, so I happily dove in with an &#8220;it&#8217;s <a href="http://python.org/">Python</a>, of course I&#8217;m going to like it&#8221; attitude.</p>
<h3>Background</h3>
<p>The book was written by <a href="http://www.holovaty.com/">Adrian Holovaty</a> and <a href="http://www.jacobian.org/">Jacob Kaplan-Moss</a>, the creators and &#8220;Benevolent Dictators&#8221; of the <a href="http://www.djangoproject.com/">Django</a> Web Framework.  It was Holovaty and Kaplan-Moss&#8217;first book, and, I believe, meant to be the first Django book to market.  The book was drafted online; open to peer-review and community feedback; and ultimately published under the GNU Free Documentation License.</p>
<p>From the get-go, the print edition had a few inherent market challenges to face: First, the entire book is available online, for free, at: &lt;<a href="http://www.djangobook.com/">http://www.djangobook.com/</a>&gt;.  Second, in many ways the book is a re-hash of the docs available at &lt;<a href="http://www.djangoproject.com/documentation/">http://www.djangoproject.com/documentation/</a>&gt;, which are also free.  Third, the book covers Django 0.96, not SVN.  (0.96 is technically the latest-snapshot release, but a lot has changed since 0.96.)  And finally, the $45 MSRP could be seen as a little steep for what is effectively a printed copy of a free, online book.</p>
<h3>The print experience</h3>
<p>Diving in, the book takes the reader through the basic installation process, provides a brief background on how the framework came to be (and why you want one), then steps through the major features (ie., the template system, ORM, URLconfs, generic views, etc.)  It&#8217;s what you&#8217;d expect from a technical reference &#8212; no fluff, and straight to the details.  There are plenty of code snippets to learn from, and the sidebar notes tend to be insightful.</p>
<p>Since it wasn&#8217;t new material for me, the book was a fairly quick read; but the experience of reading Django documentation in book-form was actually quite fascinating.  There&#8217;s something about settling into a comfortable chair with a book, pen, and highlighter that you just can&#8217;t get with online documentation.  Perhaps it was just a little more noticeable given the material.  When I read the Django docs online, I tend to skim over them while trying to solve a problem.  I use them as a reference more then a learning tool, and it&#8217;s usually while actively coding, thus my brain is partially distracted with whatever it is I&#8217;m building.</p>
<p>With a physical book, you can unplug, step away from the computer, and give the material your undivided attention.  This isolation from distraction results in a much deeper understanding of the text.  <b>This is the real the value of the printed book &mdash; it&#8217;s an opportunity to digest online documentation in an environment more conducive to learning and retention.</b></p>
<h3>My general take-aways and observations</h3>
<ul>
<li>The book definitely has a beginner/intermediate feel to it, but only in the sense of a beginner Django user &mdash; not a beginner Web developer or Python programmer.  I&#8217;m curious how well the book is received by folks who are beginners at Django and dynamic Web development since the text brings up a lot of complex topics in Web development that aren&#8217;t really explained.  (Ex., database administration, server clustering, manipulating HTTP headers, etc.)</li>
<li>The breadth of the book is impressive, but in some ways, the book really feeds you through a firehose, so to speak.  It throws a lot of new concepts at the reader and doesn&#8217;t always explain why you&#8217;d need to know them, or how you might use them in the real world.  For someone deploying a site with Django, it will be good to know that all these features are available, but it might take awhile before they need to use them (if ever.)</li>
<li>The book does touch on some of the more advanced Django features (like extending the template system and writing custom middleware), which was nice, but some topics are reserved for the appendix and get limited coverage (ex., model managers and &#8216;Q&#8217;queries.)  Others, like the Sites Framework, are given good exposure, but not so much that the reader is left with a clear picture on when to use them and what their limitations are.</li>
<li>The <a href="http://www.djangobook.com/en/1.0/chapter07/">forms processing</a> chapter was a bit lighter then what I was hoping for &#8212; especially given that the current newforms documentation still trends toward &#8220;read the source code.&#8221;  It provides enough to start using newforms if your form needs are pretty basic, but doesn&#8217;t address creating your own widgets, or any of the fun stuff you can do once you start dynamically generating and manipulating newforms objects.</li>
<li>It might have been nicer if the examples in the book were a little more tied together, perhaps all focused on building a single example project and showing how the various features are used in real-world applications.  (The example of the book-publisher&#8217;s app was a reoccurring theme, but not so strongly that each chapter applied it&#8217;s new learnings to it.)</li>
<li>The Deploying Django: &#8220;Going Big&#8221; sub-section provides a nice infrastructure graphics for how high-traffic systems might be setup, but once you get to the point of being &#8220;big&#8221;, you need to architect for it, and that&#8217;s really outside of the scope of this book.  For this section, it might have been nice to reference other resources on scaling infrastructure, and perhaps pointing out some of the ways that Django can be optimized for performance and horizontal scaling.  (For example, one of the Django projects we put into production at work will happily support 1,200 requests/second, but the database layer and session middleware have been reworked a bit, and the content caching approach is a little different then the standard Django offering.)</li>
<li>On the more positive side, <b>even as someone who&#8217;s been using Django for some time, I still learned a few new tricks</b>, and I was reminded of a few features that I could be taking better advantage of.  (And when you do this stuff professionally, every shortcut and productivity gain has monetary value &mdash; avoiding even a half-hour of debugging pays for the cost of this book.)</li>
<li><b>This book would make a fantastic read for a back-end developer joining a project that is already using Django</b>.  I normally tell new developers to go through the Python Tutorial at &lt;<a href="http://python.org/doc/tut/">http://python.org/doc/tut/</a>&gt; if they&#8217;re new to Python, then to complete the Django Tutorials at &lt;<a href="http://www.djangoproject.com/documentation/">http://www.djangoproject.com/documentation/</a>&gt; before trying to grok any in-progress Django project.  Now I have a third reference (though I might still suggest that they walk through the tutorials first, so that they have some context when reading the book.  Otherwise, there are just too many new concepts to do a straight read-through and still grasp it all.)</li>
</ul>
<h3>Summary</h3>
<p>The market needed a good Django book, and this one delivered a solid reference for the framework.  Arguably, it&#8217;s not really a &#8220;Beginner&#8217;s Guide to Django&#8221;, but hopefully it covers enough of the basics that future books can focus on best practices and more advanced techniques. (On a related note, there&#8217;s apparently an upcoming &#8220;Practical Django Projects&#8221; book, also from Apress, that will focus more on building &#8220;reusable Django applications from start to finish&#8221;.  This might actually make for a better beginner&#8217;s book, depending on how it turns out. [Via <a href="http://www.b-list.org/weblog/2007/dec/12/speaking-and-writing/">The B-List: Speaking and writing</a>].)</p>
<p>The million-dollar question then, is &#8220;<b>Should you buy this book?</b>&#8221;  My answer ended up being a bit more positive then I expected, but there are two parts:  First, if you&#8217;re a front-end developer only, you don&#8217;t need this book.  You can just read <a href="http://www.djangobook.com/en/1.0/chapter04/">Chapter 4: The Django Template System</a> online, and then use the &#8220;<a href="http://www.djangoproject.com/documentation/templates/">Django Templates: Guide for HTML authors</a>&#8221; section of the online docs as a reference.  For back-end developers, the story is different. If you&#8217;re going to just &#8220;read it while you hack&#8221;, then you might as well just read it online; but if you&#8217;re serious about building applications with Django (especially if you&#8217;re new to it), then you should consider the book and investing the time to step away from the computer and really let yourself get into it.  Unless you are an active contributor to Django (which I&#8217;m not, just to be clear), the odds are pretty good that you&#8217;ll learn something new, even if you&#8217;re already using Django today.</p>]]></content:encoded>
			<wfw:commentRss>http://www.eriksmartt.com/blog/archives/411/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django &#8220;lorem ipsum&#8221; generator (and a new contrib.webdesign module)</title>
		<link>http://www.eriksmartt.com/blog/archives/330</link>
		<comments>http://www.eriksmartt.com/blog/archives/330#comments</comments>
		<pubDate>Fri, 30 Mar 2007 15:52:53 +0000</pubDate>
		<dc:creator>erik</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.eriksmartt.com/blog/archives/330</guid>
		<description><![CDATA[Django &#8220;lorem ipsum&#8221; generator (and a new contrib.webdesign module) The Django Web Framework project just added a new contrib.webdesign module with an amazingly simple, but incredibly handy first feature: a lorem ipsum generator. The idea is that a project&#8217;s base templates can include generated lorem ipsum for testing layout and page flow, but inheriting templates [...]]]></description>
			<content:encoded><![CDATA[<p>Django &#8220;lorem ipsum&#8221; generator (and a new contrib.webdesign module)</p>
<p>The <a href="http://www.djangoproject.com/">Django</a> Web Framework project just added a new <i><a href="http://www.djangoproject.com/documentation/webdesign/">contrib.webdesign</a></i> module with an amazingly simple, but incredibly handy first feature: a <a href="http://en.wikipedia.org/wiki/Lorem_ipsum">lorem ipsum</a> generator.  The idea is that a project&#8217;s base templates can include generated lorem ipsum for testing layout and page flow, but inheriting templates can override the generated text once real content is available.</p>
<p>The <i>lorem</i> tag is used like this (via the <a href="http://www.djangoproject.com/documentation/webdesign/">contrib.webdesign</a> docs):</p>
<ul>
<li>{% lorem %} will output the common â€œlorem ipsumâ€ paragraph.</li>
<li>{% lorem 3 p %} will output the common â€œlorem ipsumâ€ paragraph and two random paragraphs each wrapped in HTML &lt;p&gt; tags.</li>
<li>{% lorem 2 w random %} will output two random Latin words.</li>
</ul>
<p>In practice, you might do this:</p>
<p><b>templates/template.html</b>:</p>
<pre><code language="text/html">
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;{% block article_title %}{% lorem 5 w %}{% endblock %}&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div class="article"&gt;
      &lt;div class="article_title"&gt;{% block article_title %}{% lorem 5 w %}{% endblock %}&lt;/div&gt;
      &lt;div class="article_body"&gt;{% block article_body %}{% lorem 4 p %}{% endblock %}&lt;/div&gt;
    &lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>And then inherit when you&#8217;re ready:</p>
<p><b>templates/article.html</b>:</p>
<pre><code language="text/html">
{% extends "template.html" %}

{% if article %}
  {% block article_title %}{{ article.title }}{% endblock %}
  {% block article_body %}{{ article.body }}{% endblock %}
{% endif %}
</code></pre>
<p>Previously, I used to just paste lorem ipsum text directly into the main template (wrapped in <i>block</i> tags for overridding), but this new tag will let you skip the copy/paste routine.  Very nice!</p>]]></content:encoded>
			<wfw:commentRss>http://www.eriksmartt.com/blog/archives/330/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyCon 2007 wrap-up</title>
		<link>http://www.eriksmartt.com/blog/archives/323</link>
		<comments>http://www.eriksmartt.com/blog/archives/323#comments</comments>
		<pubDate>Tue, 27 Feb 2007 17:16:28 +0000</pubDate>
		<dc:creator>erik</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[travel]]></category>

		<guid isPermaLink="false">http://www.eriksmartt.com/blog/archives/323</guid>
		<description><![CDATA[I&#8217;m back from PyCon 2007. It was a busy weekend, with 593 Pythonistas attending the conference. I took a fair amount of notes, but I&#8217;ve pulled out some highlights below: From Ivan Krstic&#8217;s keynote on the One Laptop Per Child project: Python is the language of the One Laptop Per Child (OLPC). Everything that can, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m back from <a href="http://us.pycon.org/TX2007/">PyCon 2007</a>.  It was a busy weekend, with 593 Pythonistas attending the conference.  I took a fair amount of notes, but I&#8217;ve pulled out some highlights below:</p>
<h2>From Ivan Krstic&#8217;s keynote on the One Laptop Per Child project:</h2>
<ul>
<li><a href="http://python.org/">Python</a> is the language of the <a href="http://dev.laptop.org/">One Laptop Per Child</a> (OLPC).  Everything that can, will be done in Python&#8230; and there&#8217;s a &#8220;view source&#8221; button on the keyboard (<a href="http://wiki.laptop.org/go/Image:Keyboard_layout.jpg">view layout</a>) so you can view (and edit) the source of your current running application.</li>
<li>The filesystem (which supports versioning) is called Yellow, and will be released withing a week or so.  The GUI is called <a href="http://wiki.laptop.org/go/Sugar">Sugar</a>, and is available on <a href="http://dev.laptop.org/">http://dev.laptop.org/</a> to play with.  You can download the full image (or build the environment on Linux.)</li>
<li>The OLPC supports 802.11s mesh networking.</li>
<li>The hand crank was removed for case durability.  The OLPC&#8217;s are designed to last five years, but the torque from the hand-crank would have stressed the plastic case too much for it to last that long.</li>
<li>The first OLPC&#8217;s will start shipping in August of this year!</li>
<li>The <a href="http://wiki.laptop.org/go/Hardware_specification">OLPC hardware</a> was getting ~1100 pystones before optimization.  They are now up to ~2300 pystones (on a 366 Mhz AMD Geode processor.)  (Note: This means they have better Python performance then <a href="http://opensource.nokia.com/projects/pythonfors60/index.html">Python for S60</a> is seeing on current <a href="http://www.s60.com/">S60</a> phones.)</li>
</ul>
<h2>From the Web Frameworks panel:</h2>
<ul>
<li>James Tauber, &#8220;Reinventing the wheel is great if your goal is to learn more about the wheel.&#8221;</li>
<li>Jonathan Ellis, &#8220;When you control the whole stack you can innovate faster.&#8221;</li>
</ul>
<h2>From Adele Goldberg&#8217;s keynote:</h2>
<blockquote><p>Public school education is so bad that real eLearning solutions can&#8217;t go to the schools &#8212; they need to be outside of schools so that you don&#8217;t have the traditional censorship that comes with public schools &#8212; and you don&#8217;t have the associates with the bad experiences kids have while at &#8220;school&#8221;.</p></blockquote>
<h2>From Jacob Kaplan-Moss&#8217;talk, &#8220;Becoming an open-source developer: Lessons from the Django project&#8221;:</h2>
<ol>
<li>Use good tools.  &#8220;Open source is better because it&#8217;s better.&#8221;</li>
<li>Avoid dogma. Don&#8217;t get stuck on what language something is implemented in.</li>
<li>Work with (and hire) smart people.  The model in open source is that if you&#8217;re smart, people listen to you.  That&#8217;s rough if you&#8217;re not smart&#8230; But also means that it&#8217;s worthwhile to mention when you&#8217;re an expert on a topic.</li>
<li>&#8220;Methodologies&#8221; suck.  Ex., MVC is cool, but Django abuses it because it doesn&#8217;t fit so well with the web.</li>
<li>DRY &#8212; Don&#8217;t Repeat Yourself.  The one methodology to use.</li>
<li>The business case for open source.  You have to make one (to your company.)
<ul>
<li>Money.  You&#8217;ll get recognized and sell services because of it.  (Ex., Ellignton wouldn&#8217;t be as successful without Django.)</li>
<li>Free labor.  (Sad to think of this way, but true when you have an interesting project.)</li>
<li>Self-improvement.  Knowing that peers will review your code makes you much more careful about the code you submit.  This makes the code a lot better.</li>
<li>
   </li>
<li>Geek cred &#8212; gaining credibility within the geek community makes it easier to hire great people.</li>
<li>Moral Argument &#8212; If you built a business on open source &#8212; it&#8217;s time to give something back.</li>
<li>Figure out where to draw the line &#8212; Django gave away the tools, but not all the apps.</li>
</ul>
</li>
<li>Selling open source to other companies.  Microsoft&#8217;s FUD had been quite successful in some areas.  Counter the &#8220;communist&#8221; argument with a &#8220;freedom&#8221; argument.  Focus on the freedom of data &#8212; your data belongs to you; there is no vendor lock-in.  Open vs. Lock-in is a better argument then Open vs. Closed.</li>
<li>Create a community.  This doesn&#8217;t just happen because you setup a mailing list.  (Gave example of thanking people who post anti-Django blog posts and asking what they didn&#8217;t like.)  Don&#8217;t say anything that would get you kicked out of a bar.
<ul>
<li>Avoid monsters (trolls, vampires, etc.)  Detect them early, and ignore them.</li>
<li>Spam can&#8217;t be an afterthought.  Collaborative tools require spam filtering from Day 1.  You&#8217;ll get spam.  Lots of it.  Google Groups is pretty good about cutting out spam.</li>
</ul>
<ul>
</ul>
</li>
<li>listen to the community. But smartly.  Sometimes the vocal majority doesn&#8217;t represent the wishes of the whole community.  Django&#8217;s magic-removal was a big risk, driven by the community.  You also have to be willing to ask for help.  Sometimes you don&#8217;t feel comfortable delegating tasks that you think suck &#8212; but not everyone has the same definition of &#8220;what sucks&#8221; &#8212; sometimes there&#8217;s someone who actually WANTS to do this task!</li>
<li>Handling community contributions.  You need a defined method for how you take contributions.  It helped the Django project when they adopted a system for differentiating between patches that are controversial, and those that aren&#8217;t.  (ie., simple bug fixes vs. design decisions.)  A ticket reviewer makes this decision.</li>
<li>Learn to be comfortable saying &#8216;no&#8217;&#8212; there are plenty of Python web frameworks, and maybe someone&#8217;s needs are better handled by another framework.  &#8220;If everyone can check in features, you have PHP.&#8221;</li>
</ol>
<h2>From &#8220;The absolute minimum an open source developer must know about intellectual property&#8221;:</h2>
<ul>
<li>It&#8217;s a lawyer&#8217;s job to figure out what will go wrong with your plan.  They are professional pessimists.</li>
<li>Only the &#8220;claims&#8221; in a patent are covered, not the stuff in the &#8220;specification.&#8221;</li>
<li>A header file is a &#8220;purely functional&#8221; expression, thus NOT-copyrightable.</li>
<li>If you don&#8217;t protect your Trademark, you lose it.  This is why companies have to send cease and desist.  The &#8220;get a first life&#8221; situation was important because Lindon explicitly granted them a license to use the Second Life trademark in the parody, thus they were able to demonstrate that they were protecting their mark.</li>
<li>If you tell someone how to do the work (ie., &#8220;work for hire&#8221;), then you own it.</li>
<li>An independent contractor owns their work unless the contract specifically assigns the rights to the company.</li>
<li>The person who made a patch owns the patch.  By giving it to you, you get an applied license to use it, but because it&#8217;s implied, it&#8217;s fuzzy as to what you can do with it.</li>
</ul>
<h2>From Robert M. Lefkowitz&#8217;s keynote:</h2>
<ul>
<li>Only 2% of the population can read source code.  (And free software doesn&#8217;t matter if no one can read it!)</li>
<li>Proprietary software values function.  Free software people value the building of the &#8220;community of learning&#8221; around the software, even if it has fewer features.</li>
<li>The traditional view is that computer literacy is about one&#8217;s ability to use applications, rather then to program.  If this is right, then what&#8217;s the point?  Computers might as well be printing presses.</li>
<li>In literature, you read the greats (ex., Shakespeare), then try to write like them.  So in computer literacy, who are the greats?  If we were going to make every high school students memorize a program, what would it be?</li>
<li>Great programmers break the rules elegantly.  Bad programmers break the rules without realizing it.</li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.eriksmartt.com/blog/archives/323/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

