<?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>Steven Harms &#187; django</title>
	<atom:link href="http://www.sharms.org/blog/tag/django/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sharms.org/blog</link>
	<description>Life, Linux and Technology</description>
	<lastBuildDate>Sun, 28 Aug 2011 18:02:56 +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>Cherokee / Django tip: Timeout value</title>
		<link>http://www.sharms.org/blog/2009/05/cherokee-django-tip-timeout-value/</link>
		<comments>http://www.sharms.org/blog/2009/05/cherokee-django-tip-timeout-value/#comments</comments>
		<pubDate>Tue, 12 May 2009 20:40:29 +0000</pubDate>
		<dc:creator>sharms</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[cherokee]]></category>
		<category><![CDATA[django]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/2009/05/12/cherokee-django-tip-timeout-value/</guid>
		<description><![CDATA[The default Cherokee timeout value is 15 seconds. I write server control dashboards which may have views which take longer than 15 seconds to render because they launch processes etc. Using Jquery / Ajax, I noticed these processes would spawn a bunch. This is because the of the default cherokee timeout. I increased this to [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2009/04/the-cherokee-webserver-great-choice-for-vpss/' rel='bookmark' title='Permanent Link: The Cherokee Webserver: Great choice for VPS&#039;s'>The Cherokee Webserver: Great choice for VPS&#039;s</a></li>
<li><a href='http://www.sharms.org/blog/2009/02/the-cherokee-webserver/' rel='bookmark' title='Permanent Link: The Cherokee Webserver'>The Cherokee Webserver</a></li>
<li><a href='http://www.sharms.org/blog/2009/06/python-threads/' rel='bookmark' title='Permanent Link: Python threads'>Python threads</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The default Cherokee timeout value is 15 seconds.  I write server control dashboards which may have views which take longer than 15 seconds to render because they launch processes etc.  Using Jquery / Ajax, I noticed these processes would spawn a bunch.  This is because the of the default cherokee timeout.  I increased this to 2400 seconds and now my problem went away.  Hope that helps someone.</p>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2009/04/the-cherokee-webserver-great-choice-for-vpss/' rel='bookmark' title='Permanent Link: The Cherokee Webserver: Great choice for VPS&#039;s'>The Cherokee Webserver: Great choice for VPS&#039;s</a></li>
<li><a href='http://www.sharms.org/blog/2009/02/the-cherokee-webserver/' rel='bookmark' title='Permanent Link: The Cherokee Webserver'>The Cherokee Webserver</a></li>
<li><a href='http://www.sharms.org/blog/2009/06/python-threads/' rel='bookmark' title='Permanent Link: Python threads'>Python threads</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2009/05/cherokee-django-tip-timeout-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Cherokee Webserver</title>
		<link>http://www.sharms.org/blog/2009/02/the-cherokee-webserver/</link>
		<comments>http://www.sharms.org/blog/2009/02/the-cherokee-webserver/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 16:15:08 +0000</pubDate>
		<dc:creator>Steven Harms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bzr]]></category>
		<category><![CDATA[cherokee]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=348</guid>
		<description><![CDATA[After seeing some of the performance graphs on Alvaro&#8217;s blog, I decided to give Cherokee a shot with a project I am working on. The project I am working on has a web browser on kiosk machines, and runs Django on the backend. I was in need of a fast, secure web server. I have [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2009/04/the-cherokee-webserver-great-choice-for-vpss/' rel='bookmark' title='Permanent Link: The Cherokee Webserver: Great choice for VPS&#039;s'>The Cherokee Webserver: Great choice for VPS&#039;s</a></li>
<li><a href='http://www.sharms.org/blog/2009/02/python-commands-module/' rel='bookmark' title='Permanent Link: Python Commands Module'>Python Commands Module</a></li>
<li><a href='http://www.sharms.org/blog/2009/03/migrated-to-a-vps/' rel='bookmark' title='Permanent Link: Migrated to a VPS'>Migrated to a VPS</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_349" class="wp-caption alignleft" style="width: 151px"><img src="http://www.sharms.org/blog/wp-content/uploads/indiankid.png" alt="Cherokee Webserver Logo" title="indiankid" width="141" height="165" class="size-full wp-image-349" /><p class="wp-caption-text">Cherokee Webserver Logo</p></div>After seeing some of the <a href="http://www.alobbs.com/1353/The_fastest_and_best_designed_among_the_modern_web_servers.html">performance graphs on Alvaro&#8217;s blog</a>, I decided to give Cherokee a shot with a project I am working on.  The project I am working on has a web browser on kiosk machines, and runs Django on the backend.  I was in need of a fast, secure web server.  I have always used Apache in the past, and have used Nginx, so I figured I should investigate Cherokee.<br />
<span id="more-348"></span><br />
<strong>Enter the Cherokee Web Server</strong><br />
Cherokee has performed great as an embedded webserver which serves my django project.  It takes about 12Mb of ram, and deals with multiple simultaneous requests near instantly.  This allows me to add features using Jquery that I would usually be afraid to bog down the system with.  You can check out the home page at: <a href="http://www.cherokee-project.com">http://www.cherokee-project.com</a></p>
<p><strong>Configuration</strong><br />
One of the best features is the web based configuration utility.  This utility allows everything to be administered from a web GUI instead of the normal command line editing.</p>
<div id="attachment_350" class="wp-caption aligncenter" style="width: 734px"><img src="http://www.sharms.org/blog/wp-content/uploads/admin_index.png" alt="Cherokee Admin Screenshot" title="admin_index" width="724" height="453" class="size-full wp-image-350" /><p class="wp-caption-text">Cherokee Admin Screenshot</p></div>
<p>The best part about this is, the file it outputs is also easy to tweak from the command line.  The syntax is very terse, which makes configuration file management a breeze.  I take my configuration file, and put it inside my project repository, using the <a href="http://www.bazaar-vcs.org">Bazaar Version Control System</a>.  This way I can keep track of the configurations and changes to them with ease.</p>
<p>The Cherokee admin also appears to be using Python, which I like since if I find a bug, I can much more readily diagnose it as the custom software I am developing is also in Python.</p>
<p><strong>Performance</strong><br />
Performance wise the pages load in what is perceived to be instantly.  My webservers are celeron boxes, with 1 gig of ram, running the <a href="http://www.gnome.org">Gnome Desktop Environment</a>.  These machines have most of their resources consumed already, so the performance I get is a testament to the carefully thought out design of Cherokee to have minimal overhead.</p>
<p><strong>Documentation</strong><br />
The Cherokee cookbook is fantastic for setting up a new webserver.  The documentation can be found at: <a href="http://www.cherokee-project.com/doc/">http://www.cherokee-project.com/doc/</a>.  You can find everything from using Django, load balancing, using mono / asp, to setting up a blog.  These recipes are very handy and easily understood.</p>
<p>If you have a new project, or even an old website, it is definitely worth giving Cherokee a look.  The Cherokee Project also provides packages for all major distributions, so you can download the .deb or .rpm at their website.</p>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2009/04/the-cherokee-webserver-great-choice-for-vpss/' rel='bookmark' title='Permanent Link: The Cherokee Webserver: Great choice for VPS&#039;s'>The Cherokee Webserver: Great choice for VPS&#039;s</a></li>
<li><a href='http://www.sharms.org/blog/2009/02/python-commands-module/' rel='bookmark' title='Permanent Link: Python Commands Module'>Python Commands Module</a></li>
<li><a href='http://www.sharms.org/blog/2009/03/migrated-to-a-vps/' rel='bookmark' title='Permanent Link: Migrated to a VPS'>Migrated to a VPS</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2009/02/the-cherokee-webserver/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Python Commands Module</title>
		<link>http://www.sharms.org/blog/2009/02/python-commands-module/</link>
		<comments>http://www.sharms.org/blog/2009/02/python-commands-module/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 21:18:45 +0000</pubDate>
		<dc:creator>Steven Harms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=333</guid>
		<description><![CDATA[Python Commands Module The Python module &#8216;commands&#8217; allows commands to be ran on the system. I frequently use this in combination with Django to launch processes. Get a directory listing: #!/usr/bin/python import commands status, output = commands.getstatusoutput('ls') print "Status: " + str(status) print "Output: " + str(output) This program will print out the directory contents [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2009/06/python-threads/' rel='bookmark' title='Permanent Link: Python threads'>Python threads</a></li>
<li><a href='http://www.sharms.org/blog/2009/02/the-cherokee-webserver/' rel='bookmark' title='Permanent Link: The Cherokee Webserver'>The Cherokee Webserver</a></li>
<li><a href='http://www.sharms.org/blog/2009/12/installing-play-framework-on-openbsd-4-6/' rel='bookmark' title='Permanent Link: Installing Play Framework on OpenBSD 4.6'>Installing Play Framework on OpenBSD 4.6</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.sharms.org/blog/wp-content/uploads/python_54.png" alt="Python logo" title="Python logo" width="54" height="54" class="alignleft size-full wp-image-339" /><strong>Python Commands Module</strong></p>
<p>The Python module &#8216;commands&#8217; allows commands to be ran on the system.  I frequently use this in combination with Django to launch processes.</p>
<p><strong>Get a directory listing:</strong><br />
<code><br />
#!/usr/bin/python<br />
import commands<br />
status, output = commands.getstatusoutput('ls')<br />
print "Status: " + str(status)<br />
print "Output: " + str(output)<br />
</code></p>
<p>This program will print out the directory contents of where you ran it from.  An important thing to note about programs in Linux in general is that on success they return 0, and anything not 0 is probably an error.  I commonly check the status of the returned code:</p>
<p><strong>Check if status is not 0:</strong><br />
<code><br />
if status != 0:<br />
&nbsp;&nbsp;&nbsp;&nbsp;print "An error occurred!"<br />
</code></p>
<p>This allows us to do some really fancy things with this module.  For instance, I created an application that is a django app that provides the user a menu to launch programs.  This runs on their Firefox browser, but will launch the programs on their system.  Each system runs it&#8217;s own Cherokee webserver locally, which is extremely lightweight and fast.  To install Cherokee to use django I followed this guide: <a href="http://www.cherokee-project.com/doc/cookbook_django.html">http://www.cherokee-project.com/doc/cookbook_django.html</a></p>
<p>The users run as the user &#8216;autologin&#8217;, however the webserver runs under the user &#8216;www&#8217;.  This is probably a bit hackish, but it works.  What I do is copy autologin&#8217;s .Xauthority file to the www user&#8217;s home directory, then launch the program as autologin using sudo.</p>
<p><strong>Launch a local X program from a django program:</strong><br />
<code><br />
def launchAutologinXProgram(commands):<br />
&nbsp;&nbsp;&nbsp;&nbsp;status, output = commands.getstatusoutput('sudo cp /home/autologin/.Xauthority /home/www/')<br />
&nbsp;&nbsp;&nbsp;&nbsp;os.spawnl(os.P_WAIT, "/usr/bin/sudo", "sudo", "-u", "autologin", "-H", "/bin/bash", "-c", 'export DISPLAY=":0.0"; . /etc/profile; nohup ' + str(commands) + ' &#038;')<br />
</code></p>
<p>Obviously you want to check the status variable and make sure it completed.  To do this you need to update your sudoers file to make the www user be able to run commands as autologin.  This is for a kiosk type setup, so www and autologin don&#8217;t have sensitive data, I am sure there is a more secure way to do it.  But it sure is fun.</p>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2009/06/python-threads/' rel='bookmark' title='Permanent Link: Python threads'>Python threads</a></li>
<li><a href='http://www.sharms.org/blog/2009/02/the-cherokee-webserver/' rel='bookmark' title='Permanent Link: The Cherokee Webserver'>The Cherokee Webserver</a></li>
<li><a href='http://www.sharms.org/blog/2009/12/installing-play-framework-on-openbsd-4-6/' rel='bookmark' title='Permanent Link: Installing Play Framework on OpenBSD 4.6'>Installing Play Framework on OpenBSD 4.6</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2009/02/python-commands-module/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

