<?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>/kb &#187; python</title>
	<atom:link href="http://grx.no/kb/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://grx.no/kb</link>
	<description>personal knowledgebase</description>
	<lastBuildDate>Wed, 15 Jun 2011 07:07:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Compile Vim in Snow Leopard</title>
		<link>http://grx.no/kb/2010/04/28/compile-vim-in-snow-leopard/</link>
		<comments>http://grx.no/kb/2010/04/28/compile-vim-in-snow-leopard/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 09:01:58 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=196</guid>
		<description><![CDATA[./configure &#8211;enable-pythoninterp &#8211;with-macsdk=10.6 via Chris Moyer: OSX, Vim, and Python.]]></description>
			<content:encoded><![CDATA[<p>./configure &#8211;enable-pythoninterp &#8211;with-macsdk=10.6</p>
<p>via <a href="http://blog.coredumped.org/2010/01/osx-vim-and-python.html">Chris Moyer: OSX, Vim, and Python</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2010/04/28/compile-vim-in-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install PIL (Python Imaging Library) in Leopard</title>
		<link>http://grx.no/kb/2010/02/07/install-pil-python-imaging-library-in-leopard/</link>
		<comments>http://grx.no/kb/2010/02/07/install-pil-python-imaging-library-in-leopard/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 11:09:32 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mac os]]></category>
		<category><![CDATA[pil]]></category>
		<category><![CDATA[pip]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[virtualenv]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=175</guid>
		<description><![CDATA[Installing modules when using pip, virtualenv and virtualenvwrapper is a breeze, but it took some time before I realized what was the easiest way to install PIL. I do it this way: pip -E PATH_TO_VIRTUALENV install http://dist.repoze.org/PIL-1.1.6.tar.gz This installs a slightly repackaged version of PIL. The latest PIL version is 1.1.7, but as far as [...]]]></description>
			<content:encoded><![CDATA[<p>Installing modules when using pip, virtualenv and virtualenvwrapper is a breeze, but it took some time before I realized what was the easiest way to install PIL.</p>
<p>I do it this way:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pip <span style="color: #660033;">-E</span> PATH_TO_VIRTUALENV <span style="color: #c20cb9; font-weight: bold;">install</span> http:<span style="color: #000000; font-weight: bold;">//</span>dist.repoze.org<span style="color: #000000; font-weight: bold;">/</span>PIL-1.1.6.tar.gz</pre></div></div>

<p>This installs <a href="http://pypi.python.org/pypi/PIL/1.1.6">a slightly repackaged</a> version of PIL. The latest PIL version is 1.1.7, but as far as I know it&#8217;s not available in this form.</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2010/02/07/install-pil-python-imaging-library-in-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chapter 7 in &#8220;Python Web Development with Django&#8221; &#8211; some notes</title>
		<link>http://grx.no/kb/2009/03/08/chapter-7-in-python-web-development-with-django-some-notes/</link>
		<comments>http://grx.no/kb/2009/03/08/chapter-7-in-python-web-development-with-django-some-notes/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 18:08:07 +0000</pubDate>
		<dc:creator>Morten Wergeland Hansen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=103</guid>
		<description><![CDATA[I am currently in the process of learning Django and have just finished chapter 7 in Python Web Development with Django. Here are some notes on how I got it working (except for the index page which still isn&#8217;t completely as expected) on an ubuntu hardy installation. The photo gallery example assumes an apache2 + [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently in the process of learning Django and have just finished chapter 7 in <a href="http://withdjango.com">Python Web Development with Django</a>. Here are some notes on how I got it working (except for the index page which still isn&#8217;t completely as expected) on an ubuntu hardy installation.</p>
<p>The photo gallery example assumes an <em>apache2</em> + <em>mod_python</em> setup. I didn&#8217;t really find it straightforward to get this running from the description in the appendix, so here is how I got it to work (after installation of <em>apache2</em> and <em>mod_python</em>, of course):</p>
<p>In <em>/etc/apache2/sites-available/default</em>, change lines:</p>
<pre>        &lt;Directory /var/www/&gt;
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        &lt;/Directory&gt;</pre>
<p>To:</p>
<pre>        &lt;Directory /var/www/&gt;
                Options Indexes FollowSymLinks MultiViews
                AllowOverride AuthConfig
                Order allow,deny
                allow from all

                AddHandler mod_python .py
                PythonHandler mod_python.publisher
                PythonDebug On
        &lt;/Directory&gt;</pre>
<p>Then I did the changes in <em>/etc/apache2/httpd.conf</em>, but slightly different from the book by adding a <code>PythonOption django.root</code> (didn&#8217;t work for me with the setup in the book):</p>
<pre>&lt;Location "/gallery/"&gt;
      SetHandler python-program
      PythonHandler django.core.handlers.modpython
      SetEnv DJANGO_SETTINGS_MODULE gallery.settings
      PythonOption django.root /gallery
      PythonDebug On
      PythonPath "['/path/to/django/root', '/home/user/django-stuff'] + sys.path"
&lt;/Location&gt;</pre>
<p>With an additional entry for media files:</p>
<pre>&lt;Location "/gallery/media"&gt;
      SetHandler none
&lt;/Location&gt;</pre>
<p>Now, I created a directory <em>/var/www/gallery</em> and a <em>/var/www/gallery/media</em> like explained in &#8220;Preparing for File Uploads&#8221; and edited <em>settings.py</em>:</p>
<p><code>MEDIA_ROOT = '/var/www/gallery/media/'</code><br />
<code>MEDIA_URL = 'http://localhost/gallery/media/'</code><br />
<code>ADMIN_MEDIA_PREFIX = 'http://localhost/gallery/media/admin/'</code></p>
<p>Where admin is a symbolic link (<em>/var/www/gallery/media/admin</em>) to the admin media directory in the Django installation. The two last entries where not mentioned in the book, but they made it work&#8230;</p>
<p>With the settings described above and the <code>PythonOption django.root</code> in <em>httpd.conf</em>, I didn&#8217;t need the section about DRY URLs. And it worked &#8211; as opposed to the stuff in the book.</p>
<p>With all the configuration stuff in place I typed the code outlined in the chapter and to begin with I couldn&#8217;t see any photos, except for the <code>thumb_url</code> in <em>items_list.html</em> (typo: <em>items_listing.html</em> in the last paragraph page 175). I managed to get it working by changing some lines in <em>items_detail.html</em> and <em>photos_detail.html</em> though:</p>
<pre>22                 &lt;img src="{{ photo.image.thumb_url }}" /&gt;</pre>
<p>instead of</p>
<pre>22                 &lt;img src="{{ photo.get_image_thumb_url }}" /&gt;</pre>
<p>and</p>
<pre>8 &lt;img src="{{ object.image.url }}" /&gt;</pre>
<p>instead of:</p>
<pre>8 &lt;img src="{{ object.get_image_url }}" /&gt;</pre>
<p>The alternatives that worked seems more intuitive to me.</p>
<p>I also imported <code>list_detail</code> from <code>django.views.generic</code> in <em>urls.py</em>, but am not sure if this was needed. The photo gallery seems to work fine except for the thumbnails in <em>index.html</em>. I&#8217;ve noticed that the code in <em>urls.py</em> for that template is different from the others, using <code>simple.direct_to_template</code>, but I haven&#8217;t managed getting that part to work.</p>
<p>Thanks to this thread for getting mod_python up and running: <a href="http://ubuntuforums.org/showthread.php?t=91101">Python and Apache2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2009/03/08/chapter-7-in-python-web-development-with-django-some-notes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Pydev in Eclipse on Mac</title>
		<link>http://grx.no/kb/2008/04/23/pydev-in-eclipse-on-mac/</link>
		<comments>http://grx.no/kb/2008/04/23/pydev-in-eclipse-on-mac/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 09:23:41 +0000</pubDate>
		<dc:creator>Håvard Grimelid</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[editing]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://k.grx.no/?p=8</guid>
		<description><![CDATA[You will be asked to specify the where Python interpreter is located: Please configure a Python or Jython interpreter in Window -&#62; Preferences -&#62; PyDev before creating a new Pydev project Press Apple key and , (Preferences) and browse to the Python Interpreters submenu Choose New in the upper right and browse to /usr/bin/python Eclipse [...]]]></description>
			<content:encoded><![CDATA[<p>You will be asked to specify the where Python interpreter is located:</p>
<blockquote><p>Please configure a Python or Jython interpreter in Window -&gt; Preferences -&gt; PyDev<br />
before creating a new Pydev project</p></blockquote>
<ul>
<li>Press Apple key and , (Preferences) and browse to the Python Interpreters submenu</li>
<li>Choose New in the upper right and browse to /usr/bin/python</li>
<li>Eclipse will then take care of the rest for you &#8211; ie. updating the $PYTHONPATH</li>
</ul>
<p>NOTE: I use Eclipse 3.3.2 on Mac OS 10.5.2.</p>
<p>Reference: <a href="http://www.dllhell.net/index.php/2008/01/27/on-using-pydev-on-a-mac/">On Using Pydev on a Mac</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2008/04/23/pydev-in-eclipse-on-mac/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

