<?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>Neural Advance</title>
	<atom:link href="http://www.neuraladvance.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.neuraladvance.com</link>
	<description>Mac OS X, UNIX and Windows Development</description>
	<lastBuildDate>Sat, 15 Oct 2011 10:46:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Removing HTML from Python Strings</title>
		<link>http://www.neuraladvance.com/2011/10/15/removing-html-python-strings/</link>
		<comments>http://www.neuraladvance.com/2011/10/15/removing-html-python-strings/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 09:44:49 +0000</pubDate>
		<dc:creator>Simon Connah</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.neuraladvance.com/?p=679</guid>
		<description><![CDATA[It is incredibly easy to remove HTML from a Python string using the lxml library. All you need to do is something similar to the below snippet: # remove HTML from the string content and place the result in doc doc = html.document_fromstring&#40;content&#41; # get the text content of doc (with no markup) and place [...]]]></description>
			<content:encoded><![CDATA[<p>It is incredibly easy to remove HTML from a Python string using the <a href="http://lxml.de/" title="lxml" target="_blank">lxml</a> library. All you need to do is something similar to the below snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># remove HTML from the string content and place the result in doc</span>
doc = html.<span style="color: black;">document_fromstring</span><span style="color: black;">&#40;</span>content<span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;"># get the text content of doc (with no markup) and place the result in text_doc </span>
text_doc = doc.<span style="color: black;">text_content</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>thus text_doc now contains the text of the original string with no HTML markup in it. Now you can use something like <a href="https://code.google.com/p/postmarkup/" title="Postmarkup" target="_blank">Postmarkup</a> so that users can use BBCode or a similar markup tool to style the text that they place on your site without having the security risk of allowing users to post HTML.</p>
<p>If you are using Django it is essential that you mark your strings as safe using the safe template tag so that Django does not automatically escape the HTML created legitimately from the BBCode.</p>
<p>A full example that uses Postmarkup and lxml to first remove any HTML in a post and then render the BBCode into HTML for display on a site:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> postmarkup <span style="color: #ff7700;font-weight:bold;">import</span> render_bbcode
<span style="color: #ff7700;font-weight:bold;">from</span> lxml <span style="color: #ff7700;font-weight:bold;">import</span> html
&nbsp;
doc = html.<span style="color: black;">document_fromstring</span><span style="color: black;">&#40;</span>content<span style="color: black;">&#41;</span>
bbcode = doc.<span style="color: black;">text_content</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
content = render_bbcode<span style="color: black;">&#40;</span>bbcode<span style="color: black;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.neuraladvance.com/2011/10/15/removing-html-python-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing XFCE 4.8 on Arch Linux</title>
		<link>http://www.neuraladvance.com/2011/09/03/xfce-arch-linux/</link>
		<comments>http://www.neuraladvance.com/2011/09/03/xfce-arch-linux/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 12:54:11 +0000</pubDate>
		<dc:creator>Simon Connah</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.neuraladvance.com/?p=665</guid>
		<description><![CDATA[This article looks at how to install XFCE 4.8 on Arch Linux. I assume that you have a clean install of Arch Linux. If you do not you may already have some of the packages installed but it won&#8217;t hurt to follow the instructions exactly as shown. The first task is to configure Arch Linux [...]]]></description>
			<content:encoded><![CDATA[<p>This article looks at how to install XFCE 4.8 on Arch Linux. I assume that you have a clean install of Arch Linux. If you do not you may already have some of the packages installed but it won&#8217;t hurt to follow the instructions exactly as shown.</p>
<p>The first task is to configure Arch Linux using the official <em><a href="https://wiki.archlinux.org/index.php/Official_Arch_Linux_Install_Guide" target="_blank">installation manual</a></em> which is excellent. I won&#8217;t be covering anything that is included in the installation guide as the provided documentation is already good enough.</p>
<p>Once you have finished with the initial configuration of Arch Linux we should move on to installing the requirements. We will be using SLiM as our login manager as that is nice and lightweight.</p>
<p>Run the following command to install all the requirements to get XFCE up and running:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pacman <span style="color: #660033;">-S</span> xfce4 ttf-liberation xorg-server dbus slim</pre></div></div>

<p>you will also need to install the correct graphics drivers for your card. The following are the likely options:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">xf86-video-ati
xf86-video-nvidia
xf86-video-intel</pre></div></div>

<p>so install the correct one for your system like so:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pacman <span style="color: #660033;">-S</span> xf86-video-ati</pre></div></div>

<p>now that is done you simply need to copy /etc/skel/.xinitrc to your home directory (and for all the other users you wish to be able to login using SLiM) like so:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>skel<span style="color: #000000; font-weight: bold;">/</span>.xinitrc ~<span style="color: #000000; font-weight: bold;">/</span>.xinitrc</pre></div></div>

<p>and uncomment the following line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># exec startxfce4</span></pre></div></div>

<p>so that it looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">exec</span> startxfce4</pre></div></div>

<p>if the line does not exist in the file then simply add it to the bottom of the file and make sure that all other exec lines are commented out.</p>
<p>Now all you need to do is add dbus and slim to your list of daemons by editing /etc/rc.conf like so:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">DAEMONS</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span>... dbus slim<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>it is vital that dbus and slim are the last two entries in the daemons list. Simply restart your computer and you should be able to login to your new XFCE 4 desktop environment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neuraladvance.com/2011/09/03/xfce-arch-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring NTPd in Arch Linux</title>
		<link>http://www.neuraladvance.com/2011/09/02/configuring-ntpd-in-arch-linux/</link>
		<comments>http://www.neuraladvance.com/2011/09/02/configuring-ntpd-in-arch-linux/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 11:18:30 +0000</pubDate>
		<dc:creator>Simon Connah</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Arch]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.neuraladvance.com/?p=655</guid>
		<description><![CDATA[This tutorial deals with getting ntpd configured so that your system clock is set over the internet. So install ntpd like so: pacman -S ntp In order to get this working visit http://www.pool.ntp.org/ and select the correct region. Once you know which ntp servers you want to use add the servers to /etc/ntp.conf as shown [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial deals with getting ntpd configured so that your system clock is set over the internet. So install ntpd like so:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pacman <span style="color: #660033;">-S</span> ntp</pre></div></div>

<p>In order to get this working visit <em><a href="http://www.pool.ntp.org/">http://www.pool.ntp.org/</a></em> and select the correct region. Once you know which ntp servers you want to use add the servers to <em>/etc/ntp.conf</em> as shown below:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">server <span style="color: #000000;">0</span>.europe.pool.ntp.org iburst
server <span style="color: #000000;">1</span>.europe.pool.ntp.org iburst
server <span style="color: #000000;">2</span>.europe.pool.ntp.org iburst
server <span style="color: #000000;">3</span>.europe.pool.ntp.org iburst</pre></div></div>

<p>substitute the servers for the correct servers in your region. The iburst option is recommended. Then we need to make sure that ntpd runs automatically so we add it to our <em>DAEMONS</em> section of the <em>/etc/rc.conf</em> file like so:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">DAEMONS</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span>... <span style="color: #000000; font-weight: bold;">!</span>hwclock ntpd ...<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>this disables the hardware clock and makes sure that ntpd is used instead to keep the time in sync.</p>
<p>Now lets just finally make sure ntpd runs as a non-root user and in a chroot environment for added security:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">groupadd ntp
useradd <span style="color: #660033;">-r</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ntp <span style="color: #660033;">-g</span> ntp <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">false</span> ntp</pre></div></div>

<p>then</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> ntp:ntp <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ntp</pre></div></div>

<p>once you have created the user and group for ntpd and changed the permissions on the <em>/var/lib/ntp</em> directory you just need to edit <em>/etc/conf.d/ntp-client.conf</em> by editing the <em>NTPD_ARGS</em> line so it looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">NTPD_ARGS</span>=<span style="color: #ff0000;">&quot;-g -i /var/lib/ntp -u ntp:ntp&quot;</span></pre></div></div>

<p>and edit <em>/etc/ntp.conf</em> so that the following line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">driftfile       <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ntp<span style="color: #000000; font-weight: bold;">/</span>ntp.drift</pre></div></div>

<p>reads:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">driftfile       <span style="color: #000000; font-weight: bold;">/</span>ntp.drift</pre></div></div>

<p>then finally restart ntpd and it should work perfectly:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rc.d restart ntpd</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.neuraladvance.com/2011/09/02/configuring-ntpd-in-arch-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Gnome 3 on Arch Linux</title>
		<link>http://www.neuraladvance.com/2011/09/02/gnome-3-arch-linux/</link>
		<comments>http://www.neuraladvance.com/2011/09/02/gnome-3-arch-linux/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 23:18:37 +0000</pubDate>
		<dc:creator>Simon Connah</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Arch]]></category>
		<category><![CDATA[Gnome]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.neuraladvance.com/?p=622</guid>
		<description><![CDATA[I have just spent the best part of my evening getting to grips with Arch Linux and I have to say it was an absolute pleasure. If you are interested in getting yourself a perfect Gnome 3 setup on your computer then hopefully this article will tell you all you need to know. I first [...]]]></description>
			<content:encoded><![CDATA[<p>I have just spent the best part of my evening getting to grips with Arch Linux and I have to say it was an absolute pleasure. If you are interested in getting yourself a perfect Gnome 3 setup on your computer then hopefully this article will tell you all you need to know.</p>
<p>I first of all installed Arch Linux using the net install media so as to get the latest packages right from the get go. If you have a reasonable internet connection I highly recommend that you follow this path.</p>
<p>I won&#8217;t cover the initial installation as that is covered already by the excellent <em><a title="Arch Linux Install Guide" href="https://wiki.archlinux.org/index.php/Official_Arch_Linux_Install_Guide">installation manual</a></em>. The only thing I will say is that if you get errors about your locale you may need to add the following to your ~/.bashrc file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LANGUAGE</span>=en_GB.UTF-<span style="color: #000000;">8</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LANG</span>=en_GB.UTF-<span style="color: #000000;">8</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LC_ALL</span>=en_GB.UTF-<span style="color: #000000;">8</span></pre></div></div>

<p>of course you&#8217;ll need to substitute the locale for the one that you want to use (the British one is used in the above example). This didn&#8217;t happen on my second install so it could be down to me getting something wrong on my first attempt.</p>
<p>Once you have completed the instructions in the installation guide we can move on to getting Gnome 3 installed and configured.</p>
<p>The first step is to create a non-root user for your own use and to also install the sudo command. The easiest way to create a new user is to use the <em>adduser</em> command.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">adduser</pre></div></div>

<p>Just follow through the commands choosing the default for all options other than the username, additional groups and your full name. For the additional groups section add the following exactly as shown:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">audio,<span style="color: #c20cb9; font-weight: bold;">lp</span>,optical,storage,video,wheel,games,power,scanner,floppy</pre></div></div>

<p>this allows the user to use the specific software in each category. If you don&#8217;t have a floppy disk drive in your computer you can leave that group out.</p>
<p>I highly recommend that you follow my guide on <em><a href="http://www.neuraladvance.com/2011/09/02/configuring-ntpd-in-arch-linux/" title="Configuring NTPd in Arch Linux">getting ntpd installed</a></em> before going further with this tutorial.</p>
<p>Now that we have ntpd properly configured we can move on to getting X11 and Gnome installed and working.</p>
<p>Installing X11 is a trivial process and simply consists of running the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pacman <span style="color: #660033;">-S</span> xorg-server</pre></div></div>

<p>you&#8217;ll also need to install the correct graphics drivers for your card. You have three options based on the type of graphics card that you have (there maybe more options but I doubt many people have a graphics card from a different manufacturer). These are listed below:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">xf86-video-ati
xf86-video-nvidia
xf86-video-intel</pre></div></div>

<p>pick the one that matches your card and install it using the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pacman <span style="color: #660033;">-S</span> xf86-video-ati</pre></div></div>

<p>obviously you&#8217;ll need to substitute the ATI drivers if you have a graphics card made by Intel or Nvidia.</p>
<p>Now that X11 is installed we can move straight on to getting Gnome 3 installed and configured. Install all the requirements as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pacman <span style="color: #660033;">-S</span> gnome gdm dbus ttf-liberation</pre></div></div>

<p>and when <em>pacman</em> asks you which packages to install just press return to select all of the options.</p>
<p>Now all you need to do is add <em>dbus</em> and <em>gdm</em> to your daemons configuration option in your <em>rc.conf</em> and away you go!</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">DAEMONS</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span>... dbus gdm<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p><strong><em>Note:</em></strong> make sure <em>dbus</em> and <em>gdm</em> are the last two items in your DAEMONS list.</p>
<p>Congratulations, you should now have a fully working Gnome 3 install on your Arch Linux box. Any other customisation you wish to do is down to you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neuraladvance.com/2011/09/02/gnome-3-arch-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Debian, Django, Nginx, FastCGI and Daemon Tools &#8211; The Perfect Combination</title>
		<link>http://www.neuraladvance.com/2011/03/29/django-nginx-fastcgi-daemontools/</link>
		<comments>http://www.neuraladvance.com/2011/03/29/django-nginx-fastcgi-daemontools/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 19:34:04 +0000</pubDate>
		<dc:creator>Simon Connah</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[FastCGI]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.neuraladvance.com/?p=546</guid>
		<description><![CDATA[Deploying a Django application can be quite confusing especially if you are a developer and not normally involved in system administration work. So what is the best configuration for hosting multiple Django sites on the same server with the lowest administrative overhead possible? Having tried Gunicorn and Nginx (which admittedly was easier to get working [...]]]></description>
			<content:encoded><![CDATA[<p>Deploying a Django application can be quite confusing especially if you are a developer and not normally involved in system administration work. So what is the best configuration for hosting multiple Django sites on the same server with the lowest administrative overhead possible?</p>
<p>Having tried Gunicorn and Nginx (which admittedly was easier to get working for a single site) I have to say that hosting Django apps using Nginx, FastCGI and Daemon Tools is by far the best method. It avoids having to write init scripts entirely (a task which is still somewhat nasty especially considering the alternatives on other non-Linux platforms such as launchd on Mac OS X which is infinitely superior).</p>
<h3><strong>Python</strong></h3>
<p>The only real requirements on the Python side are that you have <a href="http://www.virtualenv.org/">virtualenv</a> and <a href="http://trac.saddi.com/flup">flup</a> installed. Having said that using <a href="http://www.pip-installer.org/">Pip</a> and <a href="http://www.doughellmann.com/projects/virtualenvwrapper/">virtualenvwrapper</a> is also <strong>highly</strong> recommended in all Python based deployments no matter what the framework(s) you are using.</p>
<p>Also due to the fact that many Python projects make use of <a href="http://mercurial.selenic.com/">Mercurial</a> you should also take the time to learn it if you do not already know how to use it.</p>
<h3><strong>Nginx</strong></h3>
<p>The first task is to install nginx. I always install nginx from source as it allows me to cut out some the modules that I have no need for and thus reduce memory footprint a bit more. You can decide if you want to install from source or not.</p>
<p>First we need to install the dependencies for building nginx (I am using Debian 6 here so change it to whatever your platform requires):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">gcc</span> libpcre3-dev libssl-dev <span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

<p>Then run configure, make and make install:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>nginx <span style="color: #660033;">--user</span>=nginx \
<span style="color: #660033;">--group</span>=nginx --with-http_ssl_module --with-http_realip_module \
--with-http_secure_link_module --with-http_gzip_static_module \
--without-http_scgi_module --without-http_uwsgi_module \
--without-http_autoindex_module --without-http_ssi_module \
--without-http_split_clients_module --without-http_userid_module \
--without-http_memcached_module --without-mail_pop3_module \
--without-mail_imap_module --without-mail_smtp_module \
--without-http_auth_basic_module --without-http_charset_module
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">make</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>(you need to be root or use sudo when running make install).</p>
<p>Now we add the user for nginx:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">adduser <span style="color: #660033;">--system</span> <span style="color: #660033;">--no-create-home</span> <span style="color: #660033;">--disabled-login</span> \
<span style="color: #660033;">--disabled-password</span> <span style="color: #660033;">--group</span> nginx</pre></div></div>

<p>Once that is done nginx is ready to go. We just need to setup an init script for it. Since I host with <a href="http://www.linode.com/?r=22d0bd6bf05bcdeb8de4f3c8524460d62f96aa0d">Linode</a> (who are pretty darn good) I use the init script that they provide. If you use a distribution other than Debian / Ubuntu you might have to make some changes or get one specifically for your distribution.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>library.linode.com<span style="color: #000000; font-weight: bold;">/</span>webservers<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>installation<span style="color: #000000; font-weight: bold;">/</span>reference<span style="color: #000000; font-weight: bold;">/</span>init-deb.sh
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">mv</span> init-deb.sh <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nginx
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nginx
&nbsp;
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>update-rc.d <span style="color: #660033;">-f</span> nginx defaults</pre></div></div>

<p>Now nginx is installed. So lets start it and move onto the next stage. We will configure the nginx page separately after we have configured daemon tools.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nginx start</pre></div></div>

<h3><strong>Daemon Tools</strong></h3>
<p>Now lets install Daemon Tools.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> daemontools-run</pre></div></div>

<p>Once that has been completed create a directory to store our first sites configuration file. You will create a directory for every project you wish to run on the server. I generally tend to name each folder after the domain of the site to make it easy to tell which directory holds the configuration for each site (although honestly it is unlikely you will need to play around with these configuration files once they are setup and working properly).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>service<span style="color: #000000; font-weight: bold;">/</span>domain.com</pre></div></div>

<p>Now just create our configuration file for each Django project. Save it as a file called &#8220;run&#8221; (without the quotes) in the folder you created above for you domain name and then enter something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/env bash</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">source</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>your<span style="color: #000000; font-weight: bold;">/</span>virtualenv<span style="color: #000000; font-weight: bold;">/</span>for<span style="color: #000000; font-weight: bold;">/</span>project
<span style="color: #007800;">PROJ_DIR</span>=<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>django<span style="color: #000000; font-weight: bold;">/</span>project
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exec</span> envuidgid username python <span style="color: #007800;">$PROJ_DIR</span><span style="color: #000000; font-weight: bold;">/</span>manage.py \
    runfcgi <span style="color: #007800;">method</span>=threaded <span style="color: #007800;">minspare</span>=<span style="color: #000000;">1</span> <span style="color: #007800;">maxspare</span>=<span style="color: #000000;">2</span> <span style="color: #007800;">host</span>=127.0.0.1 \
    <span style="color: #007800;">port</span>=<span style="color: #000000;">9001</span> <span style="color: #007800;">pidfile</span>=<span style="color: #007800;">$PROJ_DIR</span><span style="color: #000000; font-weight: bold;">/</span>django_fcgi.pid <span style="color: #007800;">daemonize</span>=<span style="color: #c20cb9; font-weight: bold;">false</span></pre></div></div>

<p>the configuration shown above is for a very low traffic site so if you want to use it in production increase the number the maxspare option to something like 5 &#8211; 10 and the minspare to at least 2. Be aware that this will require quite a bit of free RAM so you might have to play around with options depending on how much you have available. You will also need to change &#8220;username&#8221; in the above example to the name of the user you wish to run the Django apps process.</p>
<p>Now lets us return to our nginx configuration.</p>
<h3><strong>Nginx</strong></h3>
<p>In order to avoid problems with displaying URLs in our Django application we need to add a line to nginx&#8217;s default fastcgi_params file (note that this tutorial was written using version 0.8.54 of nginx, if you are using a different version it might be worth checking if it already exists before adding it).</p>
<p>So just add the following line to the fastcgi_params file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">fastcgi_param  PATH_INFO          <span style="color: #007800;">$fastcgi_script_name</span>;</pre></div></div>

<p>then we need to add the following line to our Django projects settings.py file (personally I have a special production_settings.py file which I have imported in my settings.py file which I leave commented out during development and only uncomment when I deploy to production):</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">FORCE_SCRIPT_NAME = <span style="color: #483d8b;">''</span></pre></div></div>

<p>then we just add the correct configuration for our domain to our nginx configuration file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">server <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    listen <span style="color: #000000;">80</span>;
    server_name domain.com;
    rewrite ^<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.domain.com<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$1</span> permanent;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
server <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    listen <span style="color: #000000;">80</span>;
    server_name www.domain.com;
&nbsp;
    access_log <span style="color: #000000; font-weight: bold;">/</span>srv<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>domain.com<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>access.log;
    error_log <span style="color: #000000; font-weight: bold;">/</span>srv<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>domain.com<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>error.log;
&nbsp;
    root <span style="color: #000000; font-weight: bold;">/</span>srv<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>domain.com<span style="color: #000000; font-weight: bold;">/</span>public_html;
    index index.html;
&nbsp;
    location <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        try_files <span style="color: #007800;">$uri</span> <span style="color: #000000; font-weight: bold;">@</span>django;
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
    location <span style="color: #000000; font-weight: bold;">/</span>static <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>static;
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
    location <span style="color: #000000; font-weight: bold;">/</span>media <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>media;
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
    location <span style="color: #000000; font-weight: bold;">@</span>django <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        include <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>fastcgi_params;
        fastcgi_pass 127.0.0.1:<span style="color: #000000;">9001</span>;
        fastcgi_pass_header Authorization;
        fastcgi_intercept_errors off;
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>and away we go.</p>
<p>This is the basic setup fully configured. All we need to do now is make sure that Daemon tools is running the correct version of our app and that nginx has all the changes we have made loaded. So simply restart out domains service:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">svc <span style="color: #660033;">-du</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>service<span style="color: #000000; font-weight: bold;">/</span>domain.com<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>and restart nginx:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nginx restart</pre></div></div>

<p>for reference if you just want to stop your Django app:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">svc <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>service<span style="color: #000000; font-weight: bold;">/</span>domain.com<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>or start it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">svc <span style="color: #660033;">-u</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>service<span style="color: #000000; font-weight: bold;">/</span>domain.com<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>and now you should be able to view your site (assuming DNS has propogated) and see the spender of your new Django application running on possibly the easiest to maintain and update Django web stack available. Hopefully you use some form of distributed source code control such as Mercurial or Git. If so you should be able to update you project simply by pulling the latest version and then just restart the Daemon Tools service with:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">svc <span style="color: #660033;">-du</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>service<span style="color: #000000; font-weight: bold;">/</span>domain.com<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>I hope you have found this article useful. If so (or even if you have not) leave a comment. Also leave a comment if you have any problems and I&#8217;ll try and help you out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neuraladvance.com/2011/03/29/django-nginx-fastcgi-daemontools/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Do US Cryptographic Laws Affect Github?</title>
		<link>http://www.neuraladvance.com/2011/01/17/us-cryptographic-laws/</link>
		<comments>http://www.neuraladvance.com/2011/01/17/us-cryptographic-laws/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 03:29:08 +0000</pubDate>
		<dc:creator>Simon Connah</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Export]]></category>
		<category><![CDATA[Law]]></category>

		<guid isPermaLink="false">http://www.neuraladvance.com/?p=530</guid>
		<description><![CDATA[I started writing this blog post as a rant against the Python Pyramid framework that requires all contributors to get agreement from Agendaless.com before submitting cryptographic software to the repository but then I had another thought. Since Github is an American company they are legally required to not export certain cryptographic software. Thus any open [...]]]></description>
			<content:encoded><![CDATA[<p>I started writing this blog post as a rant against the Python Pyramid framework that requires all contributors to get agreement from Agendaless.com before submitting cryptographic software to the repository but then I had another thought.</p>
<p>Since Github is an American company they are legally required to not export certain cryptographic software. Thus any open source project that makes use of Github (or indeed any source code repository based in the US) is going to fall under US export law. I know for a fact that certain projects (OpenBSD and OpenSSH spring immediately to mind) take great pains to ensure that none of their cryptographic software is developed in places where it is export restricted to ensure that they can produce the best software possible. So from their point of view I can easily see why they would wish to avoid sites such as Github.</p>
<p>It is hard to see whether the US government could in fact force Github to limit the type of software that they did export though without irreparably damaging their business. The fact that Github has become so popular in the open source world is testament to the great service that they provide but I doubt many open source projects would sacrifice security just to use said service.</p>
<p>So is this really an issue? I have yet to hear of Github or any other company offering the same kind of service removing or limiting the export of cryptographic software, yet the sword of Damocles will forever be hanging over your head should you choose to use it.</p>
<p>Perhaps more open source software will make use of something like Gitorious which allows you to host your own repositories in a fairly pleasant manner.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neuraladvance.com/2011/01/17/us-cryptographic-laws/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AVR Assembly on Mac OS X &#8211; Your First Program</title>
		<link>http://www.neuraladvance.com/2010/12/18/avr-assembly-mac-first-program/</link>
		<comments>http://www.neuraladvance.com/2010/12/18/avr-assembly-mac-first-program/#comments</comments>
		<pubDate>Sat, 18 Dec 2010 22:51:57 +0000</pubDate>
		<dc:creator>Simon Connah</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Assembly]]></category>
		<category><![CDATA[Atmel]]></category>
		<category><![CDATA[AVR]]></category>
		<category><![CDATA[GCC]]></category>
		<category><![CDATA[Mac OS X]]></category>

		<guid isPermaLink="false">http://www.neuraladvance.com/?p=514</guid>
		<description><![CDATA[In the past I wrote an article about writing assembly programs for AVR devices on the Mac but missed a couple of important points. The major problem with my original article was that I was passing everything through the C compiler rather than just using avr-as as one should. The other problem was that I [...]]]></description>
			<content:encoded><![CDATA[<p>In the past I wrote an article about writing assembly programs for AVR devices on the Mac but missed a couple of important points.</p>
<p>The major problem with my original article was that I was passing everything through the C compiler rather than just using avr-as as one should. The other problem was that I was using the libc headers to get the names of the specific ports. The better solution is to take the include files that Atmel supply with AVR Studio 4 on the PC and just make a couple of small changes to make them work using avr-as. The include file I use for the ATmega168 can be found <a href="http://www.neuraladvance.com/wp-content/uploads/2010/12/m168.h">here</a>.</p>
<p>By using this approach there is basically no difference between the assembly that you would use in AVR Studio 4 and that you can use on your Mac. This makes the entire development process extremely easy.</p>
<p>So lets list the source code of our updated LEDon.S file from the <a href="http://www.neuraladvance.com/2010/04/11/creating-your-first-avr-assembly-program-on-mac-os-x/">original article</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">include</span> <span style="color: #7f007f;">&quot;/home/dev/m168.h&quot;</span>
&nbsp;
	rjmp init
&nbsp;
init<span style="color: #339933;">:</span>
&nbsp;
	ser r16
	<span style="color: #00007f; font-weight: bold;">out</span> DDRB<span style="color: #339933;">,</span> r16
	<span style="color: #00007f; font-weight: bold;">out</span> DDRD<span style="color: #339933;">,</span> r16
&nbsp;
	clr r16
&nbsp;
	<span style="color: #00007f; font-weight: bold;">out</span> PORTB<span style="color: #339933;">,</span> r16
	<span style="color: #00007f; font-weight: bold;">out</span> PORTD<span style="color: #339933;">,</span> r16
&nbsp;
	<span style="color: #339933;">.</span>global main
&nbsp;
main<span style="color: #339933;">:</span>
&nbsp;
	sbi PORTB<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span>
	rjmp main</pre></div></div>

<p>it should look pretty similar to the original.</p>
<p>The only real difference comes when you want to assemble it and produce a hex file which you then upload with AVRdude (as documented <a href="http://www.neuraladvance.com/2010/04/08/using-avrdude-with-the-arduino-duemilanove/">here</a>). So you do that with these commands (assuming you have saved the above file as ledon.S and that the header file I provided is stored in /home/dev &#8211; if it is different change the include line to point to the correct path):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">avr-as <span style="color: #660033;">-mmcu</span>=atmega168 <span style="color: #660033;">-o</span> ledon.out ledon.S
avr-objcopy <span style="color: #660033;">-O</span> ihex ledon.out ledon.hex</pre></div></div>

<p>this should result in a nice ledon.hex file.</p>
<p>Now that you can use the &#8220;raw&#8221; assembler you can just read the data sheets and the AVR instruction reference and use the port names as is rather than having to use the rather stupid C macros that AVR libc provides. Obviously this technique is completely cross platform and will work on any UNIX based machine, not just Macs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neuraladvance.com/2010/12/18/avr-assembly-mac-first-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Mac OS X App Store</title>
		<link>http://www.neuraladvance.com/2010/11/01/the-mac-os-x-app-store/</link>
		<comments>http://www.neuraladvance.com/2010/11/01/the-mac-os-x-app-store/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 22:42:09 +0000</pubDate>
		<dc:creator>Simon Connah</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.neuraladvance.com/?p=458</guid>
		<description><![CDATA[It has been awhile since Apple announced the Mac App Store but it has taken this long for me to decide what my opinions are on the subject. The fact that the announcement will have a huge impact on the Apple developer community as a whole is undeniable. Although I am late to the party when it comes to [...]]]></description>
			<content:encoded><![CDATA[<p>It has been awhile since Apple announced the Mac App Store but it has taken this long for me to decide what my opinions are on the subject. The fact that the announcement will have a huge impact on the Apple developer community as a whole is undeniable.</p>
<p>Although I am late to the party when it comes to discussing the new Mac OS X app store I think it should be noted that this post comes after some thought on the subject. The major disadvantage of the Mac app store is the fact that Mac OS X customers will start to see it as the only legitimate place to buy Mac software from. Apple have been very careful to make it clear that developers are free to distribute applications separately from the app store if they wish but I worry about it when I think of a consumer choosing between an app which is conveniently located on the app store and one which is not. Which app do you think they will be most likely to purchase?</p>
<p>The fact that Apple do not deny developers the chance to distribute applications on their own does not mean that the effects of the app store on the greater developer community will not be the same. If customers are trained by Apple to use the app store to look for application purchases (it seems likely that Apple will make the app store a prominent part of the next Mac OS X release) then why would a consumer even bother looking outside of the app store? Heck, they might not even think it is possible to get software anywhere else.</p>
<p>This kind of situation is one in which developers need to find a way in which to keep their applications in the publics minds if they are not going to be deploying their applications to the app store (for whatever reason, Apples restrictions seem unnecessarily harsh). This will take some very creative marketing and is something I do not envy those who are stuck with legacy applications that they have no hope of ever making compliant with the requirements that Apple have laid.</p>
<p>The other important issue at stake here is one of price. The iOS app store has basically centred around 99 cent applications, anything more than that is considered a premium price. By their very nature Mac OS X applications require much more developer work on average than iOS applications and that should be reflected in the price. Unless Apple bring iAds to Mac OS X (something that I feel is very likely) most developers may well feel they are going to be forced to lower prices to below what they would expect to charge before the app store existed.</p>
<p>Even though I have laid out some problems which I foresee occurring once Apple release the app store for Mac OS X I still think in general it will be a positive boost for Mac OS X developers. It will give them easy access to every single modern Mac owner and that is a lot of people. Those who design a popular application have the chance to make an awful lot of money on the Mac OS X app store, assuming of course you can comply with Apples requirements.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neuraladvance.com/2010/11/01/the-mac-os-x-app-store/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exploring the Django Ecosystem</title>
		<link>http://www.neuraladvance.com/2010/06/02/exploring-the-django-ecosystem/</link>
		<comments>http://www.neuraladvance.com/2010/06/02/exploring-the-django-ecosystem/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 23:43:06 +0000</pubDate>
		<dc:creator>Simon Connah</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.neuraladvance.com/?p=388</guid>
		<description><![CDATA[Since my last post I&#8217;ve spent some time looking at all the options available to Django developers. There are a vast array of different approaches one can take and the frameworks included in the core distribution are pretty solid and well documented. I am aware of the Pinax project which offers lots of already written [...]]]></description>
			<content:encoded><![CDATA[<p>Since my last <a href="http://www.neuraladvance.com/2010/05/18/django-new-users-perspective/">post</a> I&#8217;ve spent some time looking at all the options available to <a href="http://www.djangoproject.com/">Django</a> developers. There are a vast array of different approaches one can take and the frameworks included in the core distribution are pretty solid and well documented.</p>
<p>I am aware of the Pinax project which offers lots of already written Django modules but I checked fairly recently and they were still behind the Django releases by quite a margin. Whilst the project looks good and I will certainly be keeping an eye on it, I don&#8217;t think I would make use of it in a serious project. Especially considering some of the changes in Django 1.2 are so good.</p>
<p>One element of Django that I overlooked when initially going through the documentation was the generic views feature. At first glance this seems like either a redundant feature or one that is better used as a small prototyping feature but after closer inspection it is obvious that this is an extremely powerful tool. The fact that you can delegate the entire view code to the main Django distribution not only simplifies your application but also reduces the number of potential bugs that your application contains.</p>
<p>Simply put any page that either displays a list of objects of a certain model type or a single object of a certain model type is ripe for use with the generic page view feature. Thus all you need to do is implement a template and that will handle how the view is displayed, all the correct data will automatically be passed to the template for you.</p>
<p>The next important tool to talk about is the built in comment framework. This simplifies the process of allowing users to post comment against articles and the like. The first time I used Django I actually wrote a simple blog application that implemented this feature itself but while it was a little more flexible the comment framework is stable, well documented and maintained by more developers. Any failings of the comment framework are going to be offset by the increased time spent fixing bugs in your own implementation and possibly a poor design in the first place.</p>
<p>The only complaint I have is the somewhat simplistic moderation system that is currently in place. It does the trick, but is not exactly a killer feature.</p>
<p>The final thing I want to talk about is the cache framework and memcached. I was impressed when I saw that the cache framework included not only a site wide setting but one which allowed caching on a per view basis. This could potentially allow you some interesting possibilities to optimise certain parts of your site say during a Slashdot stampede while the rest of the site remains untouched. My only concern would be that the control does not extend to the object level as far as I can see. It certainly allows you access to a low level cache API which allows the caching of data when you need it but it would be nicer to have something to automatically cache an object given a certain set of parameters.</p>
<p>Anyway this has been my first post reflecting my initial exploration of the framework. I&#8217;m keen to keep going as Django really seems the perfect mix of simplicity and flexibility. Stay tuned for more information in the coming weeks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neuraladvance.com/2010/06/02/exploring-the-django-ecosystem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Look at Django from a New Users Perspective</title>
		<link>http://www.neuraladvance.com/2010/05/18/django-new-users-perspective/</link>
		<comments>http://www.neuraladvance.com/2010/05/18/django-new-users-perspective/#comments</comments>
		<pubDate>Tue, 18 May 2010 14:38:36 +0000</pubDate>
		<dc:creator>Simon Connah</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.neuraladvance.com/?p=377</guid>
		<description><![CDATA[For the last couple of weeks I have been using Django to build a website I have been meaning to work on for quite some time. I thought I would post some of my impressions of the web framework as a new user to it in the hope that someone finds it useful. I&#8217;ll save [...]]]></description>
			<content:encoded><![CDATA[<p>For the last couple of weeks I have been using Django to build a website I have been meaning to work on for quite some time. I thought I would post some of my impressions of the web framework as a new user to it in the hope that someone finds it useful. I&#8217;ll save the reasons why I chose Python and Django for another post.</p>
<p>The first thing that I noticed was the conceptual simplicity of the Django framework. I have become accustomed to frameworks which are ridiculously complicated compared to the goal that they are actually trying to achieve. So complex in fact that instead of looking good, the authors just end up looking stupid for getting so caught up in themselves. Java and C# frameworks seem to be the worst offenders when it comes to this phenomenon.</p>
<p>Setting up views and mapping URLs to those views is also extremely easy and the code that then loads a template from within said view is not going to be more than a couple of line (unless you are passing a ridiculous number of variables to the template system). This enables you to setup some complex views with a bare minimum of code. Another winning feature in my mind is the ease of producing JSON output. Whilst this is a feature of the Python standard library, querying the database and then immediately parsing it into JSON format for consumption by clients or indeed your own Javascript code on your website enables you to create complex web services with the bare minimum of fuss.</p>
<p>One of the features I need most when it comes to web frameworks is an easy way develop the application. Some web development tools require some rather complex setup to test on your own development server but I have found Django to be amazingly simple on this front. One technique I use is to set it up to use an SQLite 3 database on the local machine and test there whilst in the process of actual development and then transfer everything to the development server, change the database settings to a PostgreSQL database server, sync the database and then test the code to make sure that everything works as expected. This has lead to a much faster and easier to manage development cycle for me as I do not have to have my development server running (for PostgreSQL and Apache) in order to test the website. Instead I simply rely on the integrated development server provided by the manage.py script.</p>
<p>The integration of Markdown within the Django framework also allows you to let users create rich text in comments, forum posts and messages to one another which will certainly be appreciated by them. The only slight annoyance I have with it is that you can not limit the allowed markdown syntax which means that users can post comments in a header one style which potentially ruins your SEO for a given page.</p>
<p>Django&#8217;s project management features are pretty good too. I tend to use BBEdit on Mac OS X for my web app development and using that applications project management along with the separation of different parts of the web application by Django ensures that you never get overwhelmed by a bunch of random files that you need to remember their purpose. This makes it easy to develop modular parts of your site (a comment system for instance) independently of the parts which will actually make use of the comment system.</p>
<p>Web services, as I have said earlier, are the bread and butter of Django. It is rare nowadays for any serious website to only have web browser clients. Most offer some form of integration with desktop and mobile clients.</p>
<p>Overall I&#8217;m highly impressed with both Django and Python as a language. As this is the first real project that I have used it in it has been an eye opener. The Python standard library complements Django perfectly and being able to use the wealth of third party Python libraries available makes just about any conceivable task that you may have easy.</p>
<p>So what are you waiting for? Try it out. If you have any questions leave a comment and I&#8217;ll get back to you ASAP.</p>
<p><strong>Note:</strong></p>
<p>I started writing this article using Django 1.1.1 but since then Django 1.2 has been released. I have not had time to test the new release properly but some of the new additions certainly look good and a couple of small issues I had have been fixed. So upgrade if you can.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neuraladvance.com/2010/05/18/django-new-users-perspective/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching using disk: basic
Object Caching 502/640 objects using disk: basic

Served from: www.neuraladvance.com @ 2012-02-07 06:39:28 -->
