<?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>Guillaume Piot &#124; Application Developer &#38; User Interface Designer &#187; Python</title>
	<atom:link href="http://gpiot.com/category/development-tips/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://gpiot.com</link>
	<description></description>
	<lastBuildDate>Tue, 30 Apr 2013 08:42:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Creating a Python Package and publish it to PyPI</title>
		<link>http://gpiot.com/creating-a-python-package-and-publish-it-to-pypi/</link>
		<comments>http://gpiot.com/creating-a-python-package-and-publish-it-to-pypi/#comments</comments>
		<pubDate>Tue, 26 Feb 2013 00:14:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://gpiot.com/?p=690</guid>
		<description><![CDATA[You may have install Python packages in the past using PIP, like this: 1$ pip install django Here&#8217;s my first attempt at created my own public package. It is a Django app, which add features to the admin. Originally published [...]]]></description>
			<content:encoded><![CDATA[<p>You may have install Python packages in the past using PIP, like this:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ pip install django</div></td></tr></tbody></table></div>
<p>Here&#8217;s my first attempt at created my own public package.</p>
<p>It is a Django app, which add features to the admin. Originally published as django-admin-tools, I have decided to make a version of my own after intensively updating the original source code.</p>
<p>First, I had to make sure that my package could be used independently as a package, so any website project could use it and get the admin extended automatically. I did this by making sure they were no custom settings or custom templates in it, but rather only generic templates that would apply to any project. Custom templates being reserved for the project level.</p>
<p>Then, the code must be hosted publicly, so I have created a public repository on bitbucket here: <a href="https://bitbucket.org/guillaumepiot/cotidia-admin-tools">https://bitbucket.org/guillaumepiot/cotidia-admin-tools</a>, where I keep the latest version of the source code.</p>
<p>I have tagged a version of code in the repository, and get the download link for that version. For that you will need to download a tagged version, and upload it back to the download section of your repository.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ git tag -a v0.4.1 -m &quot;Version 0.4.1&quot;<br />
$ git push origin v0.4.1</div></td></tr></tbody></table></div>
<p>(<a href="http://git-scm.com/book/en/Git-Basics-Tagging">How to tag on GIT</a>)</p>
<p>I created the following download link for the current version: <a href="https://bitbucket.org/guillaumepiot/cotidia-admin-tools/downloads/cotidia-admin-tools-0.4.1.tar.gz">https://bitbucket.org/guillaumepiot/cotidia-admin-tools/downloads/cotidia-admin-tools-0.4.1.tar.gz</a></p>
<p><span style="color:#ff0000">Please note that although the download url works from Bitbucket, for some reason using a download url from Github will fail. For the code I have hosted on github, I had to upload manually a source code .tar.gz file to the upload section on pypi.python.org</span></p>
<p>The package source code must be organised in the following manner:</p>
<p><a href="http://gpiot.com/wp-content/uploads/2013/02/Screen-Shot-2013-02-25-at-23.49.53.png"><img class="alignnone size-full wp-image-692" title="Screen Shot 2013-02-25 at 23.49.53" src="http://gpiot.com/wp-content/uploads/2013/02/Screen-Shot-2013-02-25-at-23.49.53.png" alt="" /></a></p>
<h2>Setup.py</h2>
<p>You will require at least a <strong>setup.py</strong> file, which includes instructions about your package:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span><br />
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">distutils</span>.<span style="color: black;">core</span> <span style="color: #ff7700;font-weight:bold;">import</span> setup<br />
<span style="color: #ff7700;font-weight:bold;">from</span> setuptools <span style="color: #ff7700;font-weight:bold;">import</span> find_packages<br />
<br />
<br />
VERSION = <span style="color: #008000;">__import__</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;admin_tools&quot;</span><span style="color: black;">&#41;</span>.__version__<br />
<br />
CLASSIFIERS = <span style="color: black;">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #483d8b;">'Framework :: Django'</span>,<br />
&nbsp; &nbsp; <span style="color: #483d8b;">'Intended Audience :: Developers'</span>,<br />
&nbsp; &nbsp; <span style="color: #483d8b;">'License :: OSI Approved :: BSD License'</span>,<br />
&nbsp; &nbsp; <span style="color: #483d8b;">'Operating System :: OS Independent'</span>,<br />
&nbsp; &nbsp; <span style="color: #483d8b;">'Topic :: Software Development'</span>,<br />
<span style="color: black;">&#93;</span><br />
<br />
install_requires = <span style="color: black;">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #483d8b;">'django&gt;=1.4.1'</span>,<br />
<span style="color: black;">&#93;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># taken from django-registration</span><br />
<span style="color: #808080; font-style: italic;"># Compile the list of packages available, because distutils doesn't have</span><br />
<span style="color: #808080; font-style: italic;"># an easy way to do this.</span><br />
packages, data_files = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>, <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
root_dir = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">dirname</span><span style="color: black;">&#40;</span>__file__<span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">if</span> root_dir:<br />
&nbsp; &nbsp; <span style="color: #dc143c;">os</span>.<span style="color: black;">chdir</span><span style="color: black;">&#40;</span>root_dir<span style="color: black;">&#41;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">for</span> dirpath, dirnames, filenames <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">walk</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'admin_tools'</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Ignore dirnames that start with '.'</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> i, dirname <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">enumerate</span><span style="color: black;">&#40;</span>dirnames<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> dirname.<span style="color: black;">startswith</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'.'</span><span style="color: black;">&#41;</span>: <span style="color: #ff7700;font-weight:bold;">del</span> dirnames<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #483d8b;">'__init__.py'</span> <span style="color: #ff7700;font-weight:bold;">in</span> filenames:<br />
&nbsp; &nbsp; &nbsp; &nbsp; pkg = dirpath.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">sep</span>, <span style="color: #483d8b;">'.'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">altsep</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pkg = pkg.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">altsep</span>, <span style="color: #483d8b;">'.'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; packages.<span style="color: black;">append</span><span style="color: black;">&#40;</span>pkg<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> filenames:<br />
&nbsp; &nbsp; &nbsp; &nbsp; prefix = dirpath<span style="color: black;">&#91;</span><span style="color: #ff4500;">12</span>:<span style="color: black;">&#93;</span> <span style="color: #808080; font-style: italic;"># Strip &quot;admin_tools/&quot; or &quot;admin_tools\&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> f <span style="color: #ff7700;font-weight:bold;">in</span> filenames:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data_files.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>prefix, f<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<br />
<br />
setup<span style="color: black;">&#40;</span><br />
&nbsp; &nbsp; name=<span style="color: #483d8b;">&quot;cotidia-admin-tools&quot;</span>,<br />
&nbsp; &nbsp; description=<span style="color: #483d8b;">&quot;Django application to add features to the original admin&quot;</span>,<br />
&nbsp; &nbsp; version=VERSION,<br />
&nbsp; &nbsp; author=<span style="color: #483d8b;">&quot;Guillaume Piot&quot;</span>,<br />
&nbsp; &nbsp; author_email=<span style="color: #483d8b;">&quot;guillaume@cotidia.com&quot;</span>,<br />
&nbsp; &nbsp; url=<span style="color: #483d8b;">&quot;https://bitbucket.org/guillaumepiot/cotidia-admin-tools&quot;</span>,<br />
&nbsp; &nbsp; download_url=<span style="color: #483d8b;">&quot;https://bitbucket.org/guillaumepiot/cotidia-admin-tools/downloads/cotidia-admin-tools-0.4.1.tar.gz&quot;</span>,<br />
&nbsp; &nbsp; package_dir=<span style="color: black;">&#123;</span><span style="color: #483d8b;">'admin_tools'</span>: <span style="color: #483d8b;">'admin_tools'</span><span style="color: black;">&#125;</span>,<br />
&nbsp; &nbsp; packages=packages,<br />
&nbsp; &nbsp; package_data=<span style="color: black;">&#123;</span><span style="color: #483d8b;">'admin_tools'</span>: data_files<span style="color: black;">&#125;</span>,<br />
&nbsp; &nbsp; include_package_data=<span style="color: #008000;">True</span>,<br />
&nbsp; &nbsp; install_requires=install_requires,<br />
&nbsp; &nbsp; classifiers=CLASSIFIERS,<br />
<span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<h2>AUTHORS</h2>
<p>It is important to include who has worked on the code and more importantly any past contributors which may have originated the code.</p>
<p>In my example, I have taken over someone else&#8217;s work so I have kept their name referenced in that file.</p>
<h2>README.md</h2>
<p>The holy mardown file. Explaining how to install, configure and manage your package is very important. A non-documented code is just not good enough!</p>
<h2>Testing the package</h2>
<p>Before register our package with PyPI, it is important to test if the package actually works.</p>
<p>I first install it using the repository as a reference:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ pip install -e git+https://guillaumepiot@bitbucket.org/guillaumepiot/cotidia-admin-tools.git#egg=admin_tools</div></td></tr></tbody></table></div>
<p>Note the &#8216;-e&#8217; argument. This will keep the source code in a &#8216;../src&#8217; folder, so it is easily accessible to make further changes if necessary during the development phase, or even for future improvements.</p>
<p>If it all works fine, then you are ready to register it publicly.</p>
<p>You will need an account on <a href="http://pypi.python.org">pypi.python.org</a> to author a package, so you will need to <a href="https://pypi.python.org/pypi?%3Aaction=register_form">register</a> first.</p>
<p>Once your account has been confirmed, you will be able to publish your package using the following command:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ python setup.py register</div></td></tr></tbody></table></div>
<p>You will be prompted will an authentication method to complete the registration, where I used my username and password as credentials.</p>
<p>Then a quick look up on PIP revealed my newly published package</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Guillaumes-MacBook-Pro:cotidia-admin-tools guillaumepiot$ pip search cotidia<br />
<br />
cotidia-admin-tools       - Django application to add features to the original admin</div></td></tr></tbody></table></div>
<p>I would definitely recommend to publish a useful package for the community first, but also to improve your workflow building new projects, and keeping your code easy to improve and update across multiple projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://gpiot.com/creating-a-python-package-and-publish-it-to-pypi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sublime Text 2: moving on from Textmate</title>
		<link>http://gpiot.com/sublime-text-2-moving-on-from-textmate/</link>
		<comments>http://gpiot.com/sublime-text-2-moving-on-from-textmate/#comments</comments>
		<pubDate>Tue, 02 Oct 2012 09:23:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://gpiot.com/?p=611</guid>
		<description><![CDATA[After 4 years of loyal service from Textmate, it was time to an upgrade in order to improve my coding productivity. The long waited Textmate 2 being converted to an open source project still at an alpha stage hasn&#8217;t made [...]]]></description>
			<content:encoded><![CDATA[<p>After 4 years of loyal service from <a href="http://macromates.com/">Textmate</a>, it was time to an upgrade in order to improve my coding productivity.</p>
<p>The long waited Textmate 2 being converted to an <a href="http://thenextweb.com/apps/2012/08/09/the-long-delayed-textmate-2-text-editor-open-sourced/">open source project</a> still at an alpha stage hasn&#8217;t made it a tool of choice for me.</p>
<p>Luckily, my fellow developer <a href="https://twitter.com/kin_hung">@kin_hung</a> has been using Sublime Text 2 for quite a while and has showed me a list of useful packages that could seriously increase my productivity. So the choice was made.</p>
<p>I have listed some cool packages I have installed so far, but I probably will add more later on as I discover them so it&#8217;ll be worth keeping an eye on this article.</p>
<h2>First, let&#8217;s get a package installer</h2>
<p>This will allow us to install (almost) any package from the Sublime command line which is a big time saver.</p>
<p>Follow the instructions on this page:</p>
<p><a href="http://wbond.net/sublime_packages/package_control/installation">http://wbond.net/sublime_packages/package_control/installation</a></p>
<p>Or simply type the following in your Sublime console (Menu &gt; View &gt; Show Console):</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'</div></td></tr></tbody></table></div>
<h2>Django templates, model fields &amp; form fields</h2>
<p><a href="https://github.com/squ1b3r/Djaneiro">https://github.com/squ1b3r/Djaneiro</a></p>
<p>It really eases up writing Django code, I&#8217;m so glad I don&#8217;t need to write {% %} ever again!</p>
<h3>Template examples</h3>
<table border="1" width="100%">
<tbody>
<tr>
<td width="25%"><strong>if</strong></td>
<td><tt>&gt; {% if %} {% endif %}</tt></td>
</tr>
<tr>
<td><strong>ifchanged </strong></td>
<td><tt>&gt; {% ifchanged %} {% endifchanged %}</tt></td>
</tr>
<tr>
<td><strong>ife</strong></td>
<td><tt>&gt; {% if %} {% else %} {% endif %}</tt></td>
</tr>
<tr>
<td><strong>ifelse</strong></td>
<td><tt>&gt; {% if %} {% else %} {% endif %}</tt></td>
</tr>
</tbody>
</table>
<h3>Model field examples</h3>
<table border="1" width="100%">
<tbody>
<tr>
<td width="25%"><strong>memail</strong></td>
<td><tt>&gt; models.EmailField()</tt></td>
</tr>
<tr>
<td><strong>mfile</strong></td>
<td><tt>&gt; models.FileField()</tt></td>
</tr>
</tbody>
</table>
<h3>Form field examples</h3>
<table border="1" width="100%">
<tbody>
<tr>
<td width="25%"><strong>fdate</strong></td>
<td><tt>&gt; forms.DateField()</tt></td>
</tr>
<tr>
<td><strong>fdatetime</strong></td>
<td><tt>&gt; forms.DateTime()</tt></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h2>HTML &amp; CSS high speed coding</h2>
<p><a href="http://code.google.com/p/zen-coding/">http://code.google.com/p/zen-coding/</a><br />
This is the most intuitive way I have seen to shortcut HTML. You can write a string like this:</p>
<p><strong>div#page&gt;div.logo+ul#navigation&gt;li*5&gt;a</strong></p>
<p><strong> </strong><br />
&#8230; and it will generate this:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;page&quot;</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">ul</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;navigation&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">ul</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span></div></td></tr></tbody></table></div>
<p>That&#8217;s at least 30s saved!</p>
<h2>Jquery</h2>
<p>A long list of jQuery shortcut that will save you plenty of time again.</p>
<p><a href="https://github.com/mrmartineau/jQuery">https://github.com/mrmartineau/jQuery</a></p>
<table border="1" width="100%">
<tbody>
<tr>
<td width="25%"><strong>$</strong></td>
<td><tt>&gt; $('#select DOM Element')</tt></td>
</tr>
<tr>
<td><strong>.click</strong></td>
<td><tt>&gt; .click(${1:function(${2:event}) {	${0:// Act on the event}\}});&nbsp;</p>
<p></tt><tt></tt><tt></tt><tt></tt><tt></tt><tt></tt><tt></tt><tt></tt></td>
</tr>
</tbody>
</table>
<h2>Tutorials</h2>
<p>If you wish to dig deeper into Sublime Text 2, then I recommend reading this tutorial:</p>
<p><a href="https://tutsplus.com/course/improve-workflow-in-sublime-text-2/">https://tutsplus.com/course/improve-workflow-in-sublime-text-2/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gpiot.com/sublime-text-2-moving-on-from-textmate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Burrst.com: A glimpse under the bonnet</title>
		<link>http://gpiot.com/burrst-com-a-glimpse-under-the-bonnet/</link>
		<comments>http://gpiot.com/burrst-com-a-glimpse-under-the-bonnet/#comments</comments>
		<pubDate>Thu, 06 Sep 2012 16:08:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Digital trends]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tornado]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://gpiot.com/?p=584</guid>
		<description><![CDATA[One of my very respected web developer friend, Anthony Blackshaw (Getme Ltd) has released earlier this month a brand new way to publish and share short pieces of fiction written by anyone who wants to have a try at writing [...]]]></description>
			<content:encoded><![CDATA[<p>One of my very respected web developer friend, <a href="https://twitter.com/getmeweb">Anthony Blackshaw</a> (<a href="http://www.getme.co.uk/">Getme Ltd</a>) has released earlier this month a brand new way to publish and share short pieces of fiction written by anyone who wants to have a try at writing (or already is an author!) and is seeking constructive feedback.</p>
<p>Content quality is ensured on a registration process by approval, where each first fiction piece is reviewed by a moderator before according the &#8216;publisher&#8217; account type to the registrant.</p>
<p>On the same lines a <a href="http://dribbble.com">Dribbble.com</a>, <a href="http://burrst.com">Burrst</a> will maintain high quality content by selecting only the worthwhile. Looking back on the success on Dribbble, I&#8217;m sure this will have positive effects on the website.</p>
<p>Being a web developer and therefore very curious about what is powering this site, I have collected from Anthony a few things that I will share with you now.</p>
<p><a href="http://gpiot.com/wp-content/uploads/2012/09/homepage.jpg"><img class="alignnone size-full wp-image-597" title="homepage" src="http://gpiot.com/wp-content/uploads/2012/09/homepage.jpg" alt="" /></a></p>
<h2>So, what is Burrst.com built on?</h2>
<p>Burrst is built on <a href="http://www.tornadoweb.org/">Tornado</a>, a lightweight Python framework which has the unusual advantage of being an asynchronous web server as well (great for live notifications which we&#8217;ll discuss further down).</p>
<p><strong>But why Tornado and not Django for example?</strong></p>
<p>Well, Tornado is lightening fast (hence the name) and Ant like his applications to be fast (we all do really). So by being lightweight and well written, the result are staggering: under 300ms page load and under 500ms for a fully loaded home page, that&#8217;s just about the time to see the loading spin appearing in your browser window.</p>
<p>Speed is such as an important factor in application success, users tend to get frustrated after <strong>1s</strong> an will probably leave at <strong>4s</strong>, the whole user experience starts with speed, and more generally, responsiveness.</p>
<h2>Template engine</h2>
<p>Tornado is equipped with a lightweight template processor which works by inheritance (in the same way as django does) but don&#8217;t allow includes. You can run raw Python in the template but that may not be the best practice, keeping the logic away from the view lead to leaner code.</p>
<h2>Form management</h2>
<p>This is where things start to get tight. The built in form system is limited and is likely to be insufficient to build public apps, where a high level of validation, security and variety of fields are required. So Burrst has turned its eyes towards <a href="http://wtforms.simplecodes.com/docs/1.0.2/">wtForms</a>, a much more complete package that plugs in easily in Tornado, providing it with the necessary form tools, considerably diminishing the amount of development work.</p>
<p><a href="http://gpiot.com/wp-content/uploads/2012/09/form.jpg"><img class="alignnone size-full wp-image-598" title="form" src="http://gpiot.com/wp-content/uploads/2012/09/form.jpg" alt="" /></a></p>
<h2>Database handling</h2>
<p>Tornado comes with a MySQL database handler but speed is not its forte. So it has been a wise decision to turn to <a href="https://storm.canonical.com/">Storm</a>, a super fast database handler. Storm has the advantage to bundle up a series of queries before applying them, increasing processor efficiency, and also provide query result caching for accelerating those recurring query tasks.</p>
<p>One downside of Storm is that its developer haven&#8217;t completed the documentation, which that you will have to dig in the source to really get the best out of it.</p>
<h2>Search</h2>
<p>One thing that Tornado does not cover is a search engine. So <a href="http://pypi.python.org/pypi/Whoosh/">Woosh</a> have been implemented for its ease of use and fast search.</p>
<p>Just like creating a model in Django, Woosh allow the creation of search index objects where one can specify which attribute they want to feed in the index for later being queried against.</p>
<p>Index generation is not automatic so a recurring job must be in place to regularly update the index with new content. Alternatively, it could be updated when a user save new content but that may lead to an extra delay in page processing, unless you are using a Python queuing process so it won&#8217;t affect the immediate page load.</p>
<p>Overall it may also add on computer cycle which can be optimise by having a single global update during quiet times. I have recently integrated <a href="https://mixpanel.com/">Mixpanel</a> for application event tracking, and they strongly advise to use a python queuing processing to send tracking call without delaying the page load.</p>
<p><a href="http://gpiot.com/wp-content/uploads/2012/09/search.jpg"><img class="alignnone size-full wp-image-599" title="search" src="http://gpiot.com/wp-content/uploads/2012/09/search.jpg" alt="" /></a></p>
<h2>Cloud server</h2>
<p>Burrst is running on the very famous Amazon EC2 platform, using a micro-instance (yes, micro!) to render an average of <strong>35000 pages</strong> a month without a problem, thanks to the efficiency of the application. The instance offers <strong>613MB</strong> of RAM and run on a 64bits core.<br />
All media files are hosed on the S3 CDN, once again lightening the load on the micro-instance.</p>
<p><a href="http://gpiot.com/wp-content/uploads/2012/09/post.jpg"><img class="alignnone size-full wp-image-601" title="post" src="http://gpiot.com/wp-content/uploads/2012/09/post.jpg" alt="" /></a></p>
<h2>From idea to product</h2>
<p>The process of delivering Burrst has been surprisingly fast, fitting is today&#8217;s modern <a href="http://velocitylaws.com/">laws of velocity </a>where delivering small but fast and adapting along the way to the user needs is key to success.</p>
<p>The project has started on <strong>January 1st, 2012</strong>, from Anthony passion for writing fiction and not having an exclusive, content quality checked website to do so. It was time to offer a service that bring good prose to highlights rather being buried in a pile of mediocre work.</p>
<p>Only 6 months down the line, after a regular dedicated amount of hard work, Burrst was ready to hit the wild at the <strong>end of June 2012</strong>.</p>
<p>And it&#8217;s been an impressive start with already <strong>131,283 words</strong> burrsted and nearly 200 members within the first 3 months.</p>
<p>The project has been a success so far, I believe first for its concept but undeniably propelled by the quality of the service delivered, in terms of content, usability and speed.</p>
]]></content:encoded>
			<wfw:commentRss>http://gpiot.com/burrst-com-a-glimpse-under-the-bonnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amadeus Interactive Content Map: 100,000 flight data records packed in a single friendly interface</title>
		<link>http://gpiot.com/amadeus-interactive-content-map-over-100000-flight-data-records-packed-in-a-single-friendly-interface/</link>
		<comments>http://gpiot.com/amadeus-interactive-content-map-over-100000-flight-data-records-packed-in-a-single-friendly-interface/#comments</comments>
		<pubDate>Mon, 09 Jul 2012 14:07:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Recent work]]></category>

		<guid isPermaLink="false">http://gpiot.com/?p=534</guid>
		<description><![CDATA[The Interactive Content Map has just been officially launched by Amadeus, a project I have been developing for the last 6 months at VIVA Aspire. The project has been both a data processing and a user interface challenge. The amount [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.amadeus.com/content">Interactive Content Map</a> has just been officially launched by <a href="http://www.amadeus.com">Amadeus</a>, a project I have been developing for the last 6 months at <a href="http://www.viva-aspire.com">VIVA Aspire</a>.</p>
<p>The project has been both a data processing and a user interface challenge. The amount of data that Amadeus deals with on a daily basis is enormous, and we have had the priviledge to work a sample of no less than:</p>
<ul>
<li>4,000 airports</li>
<li>500 airlines</li>
<li>90,000 routes</li>
</ul>
<p>We have worked hard at VIVA to condense all the data into an attractive and easy to use interface, so anyone can look for flights and find out about booking instructions. Even wondered who fly from where and to? Well, there&#8217;s a now an app for that!</p>
<h2>So let&#8217;s get started</h2>
<p>We first choose a region to start from before the website clusters the data for us.</p>
<p><a href="http://gpiot.com/wp-content/uploads/2012/07/routemap-screen-1.png"><img class="alignnone size-full wp-image-536" title="routemap-screen-1" src="http://gpiot.com/wp-content/uploads/2012/07/routemap-screen-1.png" alt="" width="630" height="440" /></a></p>
<h2>Step 1: clustering the data</h2>
<p>4,000 airports is a lot, especially when it&#8217;s down to plot them one by one on a Google map. The likeliness is that, your computer may be short on memory being old or simply busy on other tasks, making the plotting a tremendous effort.</p>
<p>So we had to come up with a solution, that is, clustering the airports into hot spots.</p>
<p>I have implemented a <a href="http://en.wikipedia.org/wiki/K-means_clustering">K-means algorithm</a>, which basically plots a limited number of points on a surface area, then associate each airport to its nearest point (using Haversine formula for distance calculation on a sphere using geo-location points), and finally re-adjust each point at the center of its respective hot spot area. By recursing the algorithm about 3 times, we get a pretty accurate representation of the hot area, enabling us to draw a cluster.</p>
<p>The calculation is pretty intense, but with the right amount of Python optimisation (thanks to <a href="https://twitter.com/#!/GetmeWeb">Anthony Blackshaw</a> at <a href="http://www.getme.co.uk/">Getme</a> for his contribution), we managed to get the calculation done to less than a second!</p>
<p><a href="http://gpiot.com/wp-content/uploads/2012/07/routemap-screen-2.png"><img class="alignnone size-full wp-image-537" title="routemap-screen-2" src="http://gpiot.com/wp-content/uploads/2012/07/routemap-screen-2.png" alt="" width="630" height="440" /></a></p>
<h2>Step 2: Making your journey</h2>
<p>With a clever &#8220;type ahead&#8221; airport search, a user can quickly look for the airpot he would like to depart from, and then see all the routes that the airport offers.</p>
<p>After selecting a destination, the application will give the user a list of carriers that flight the selected route, where one must be picked in order to continue with the journey.</p>
<p>One after the other, the application will remember your path and draw your entire journey before your eyes.</p>
<p><a href="http://gpiot.com/wp-content/uploads/2012/07/routemap-screen-3.png"><img class="alignnone size-full wp-image-538" title="routemap-screen-3" src="http://gpiot.com/wp-content/uploads/2012/07/routemap-screen-3.png" alt="" width="630" height="440" /></a></p>
<p>A summary screen will then present you the list of flights, which you can remove at your convenience. The application will then re-draw your journey automatically.</p>
<h2>Step 3: Export the booking instructions</h2>
<p>The application will compile the journey summary and all the information related to each carrier into a neat and tidy PDF document.</p>
<p>This step might be too far for the usual curious, but it is a gold mine for travel agencies, who can instantly access a wide range of details about the airlines such as booking processes and ancillary services.</p>
<p><a href="http://gpiot.com/wp-content/uploads/2012/07/routemap-screen-4.png"><img class="alignnone size-full wp-image-539" title="routemap-screen-4" src="http://gpiot.com/wp-content/uploads/2012/07/routemap-screen-4.png" alt="" width="630" height="440" /></a></p>
<p>&nbsp;</p>
<p>I strongly invite you to <a href="http://www.amadeus.com/content">try the application</a> for yourself and see if it works for you</p>
<p>Feel free to send us your feedback in the comment area below, good or bad, it will always be appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://gpiot.com/amadeus-interactive-content-map-over-100000-flight-data-records-packed-in-a-single-friendly-interface/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Euros 2012 website: Social stats have never been so exiting</title>
		<link>http://gpiot.com/the-euros-2012-website-social-stats-have-never-been-so-exiting/</link>
		<comments>http://gpiot.com/the-euros-2012-website-social-stats-have-never-been-so-exiting/#comments</comments>
		<pubDate>Wed, 20 Jun 2012 10:24:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Digital trends]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Recent work]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://gpiot.com/?p=508</guid>
		<description><![CDATA[I would like to introduce you to my latest development project at VIVA Aspire. The project is about demonstrating the impact of football players performance (whether good or bad) on the pitch and how it affects their social media print off it. [...]]]></description>
			<content:encoded><![CDATA[<p>I would like to introduce you to my latest development project at <a href="http://www.viva-aspire.com">VIVA Aspire</a>.</p>
<p>The project is about demonstrating the impact of football players performance (whether good or bad) on the pitch and how it affects their social media print off it.</p>
<p><a href="http://twitter.com/cj_viva">Chris Jones</a> &amp; <a href="http://twitter.com/gbviva">Gary Blowers</a> have been doing a great job in writing consistently fresh content, pulling out and explaining some social facts we can see on the graph, along with interesting feedback on the players performances.</p>
<p>The design was created by <a href="http://twitter.com/gavinauty">Gavin Auty</a>, and I have worked on a few refinement of the UI for optimal ease of use.</p>
<h2>How does it work</h2>
<p>The website is equiped with a cron job (a schedule task on the server), which fetches data every 30 mins for a list of players owning a Twitter and/or Facebook account. The data is then saved in a database (over 90,000 rows so far!) to be later processed by the charts.</p>
<p>In order to display a nice graph, we need to generate an array of values every 30 mins between a start date and end date. I had to program an <strong>extrapolation</strong> script which covers for missing data points. As good as Twitter&#8217;s API is, we do get the odd connection lost, which means we have holes in the data. Using the extrapolation, we just use the previous values if the current one is missing, avoiding holes in the graphs.</p>
<h2>Datatainment</h2>
<p>Once we had the data nicely processed, it was time to display it a beautiful charts. Lack of time forced me to use a third party chart code (<a href="http://amcharts.com">amcharts.com</a>) which in the end proved to be a great asset of the site.</p>
<p>We feed the data to the chart using a JSON data object that we get from an AJAX call. The data object is then processed in the chart into a beautiful line graph, which also allows you to refine the view by zooming and slicing.</p>
<p><a href="http://gpiot.com/wp-content/uploads/2012/06/Screen-Shot-2012-06-20-at-11.21.14.jpg"><img class="alignnone size-full wp-image-515" title="Screen-Shot-2012-06-20-at-11.21.14" src="http://gpiot.com/wp-content/uploads/2012/06/Screen-Shot-2012-06-20-at-11.21.14.jpg" alt="" width="630" height="534" /></a></p>
<h2>Putting it all together</h2>
<p>One of the biggest challenge has been to layout the home page of the site in a way that tell the visitor what is this all about in a single glance. Having using great imagery for the blog articles, we have featured a quick stat view on the right hand side which allow the visitor to quickly play around, but mainly give an incentive to use the great charts we produce.</p>
<p>Then comes the tournament results and fixtures for reference and how to connect with our social network.</p>
<p>We also decided to support <a href="http://www.gosh.org">The Great Ormond Street Hospital</a> by giving a small donation for each unique visitors we get on the site.</p>
<p><a href="http://gpiot.com/wp-content/uploads/2012/06/Screen-Shot-2012-06-20-at-11.22.50.jpg"><img class="alignnone size-full wp-image-516" title="Screen-Shot-2012-06-20-at-11.22.50" src="http://gpiot.com/wp-content/uploads/2012/06/Screen-Shot-2012-06-20-at-11.22.50.jpg" alt="" width="630" height="486" /></a></p>
<h2>Oh and also, it&#8217;s fully responsive.</h2>
<p><a href="http://gpiot.com/wp-content/uploads/2012/06/euros-2012-responsive.png"><img class="alignnone size-full wp-image-520" title="euros-2012-responsive" src="http://gpiot.com/wp-content/uploads/2012/06/euros-2012-responsive.png" alt="" width="630" height="400" /></a></p>
<p>Feel free to post any comment here about the site, any feedback is always welcome (good or bad).</p>
]]></content:encoded>
			<wfw:commentRss>http://gpiot.com/the-euros-2012-website-social-stats-have-never-been-so-exiting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django internationalization on OSX Lion</title>
		<link>http://gpiot.com/django-internationalization-on-osx-lion/</link>
		<comments>http://gpiot.com/django-internationalization-on-osx-lion/#comments</comments>
		<pubDate>Wed, 06 Jun 2012 14:42:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Mac OSX Lion]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://gpiot.com/?p=484</guid>
		<description><![CDATA[Django has excellent support for website internationalization. We will now focus on the languages side of things. First of all, we need to make sure that our Mac has the right library to generate translation files. Installing gettext If you [...]]]></description>
			<content:encoded><![CDATA[<p>Django has excellent support for website internationalization. We will now focus on the languages side of things.</p>
<p>First of all, we need to make sure that our Mac has the right library to generate translation files.</p>
<h2>Installing gettext</h2>
<p>If you run the following command in Terminal:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ django-admin.py makemessages -a</div></td></tr></tbody></table></div>
<p>You will probably get the following error</p>
<p><span style="color: #ff0000;">/bin/sh: xgettext: command not found</span></p>
<p>The reason for this is that the <strong>gettext</strong> library is not installed.</p>
<h3>Installation from source (#fail)</h3>
<p>I have tried to <a href="http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.1.1.tar.gz">download the gettext source</a> (if not available, check the gettext site: <a href="http://www.gnu.org/software/gettext/">www.gnu.org/software/gettext/</a>)</p>
<p>Uncompress the package in finder, then in Terminal cd to it:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ cd /your/path/gettext-0.18.1.1<br />
$ ./configure<br />
$ make<br />
$ make install</div></td></tr></tbody></table></div>
<p>But then I got the following error:</p>
<p><span style="color: #ff0000;">stpncpy.c:34: error: expected declaration specifiers or ‘&#8230;’ before numeric constantstpncpy.c:34: error: expected ‘)’ before ‘!=’ token</span><br />
<span style="color: #ff0000;"> stpncpy.c:34: error: expected ‘)’ before ‘?’ token</span><br />
<span style="color: #ff0000;"> make[3]: *** [stpncpy.lo] Error 1</span><br />
<span style="color: #ff0000;"> make[2]: *** [install] Error 2</span><br />
<span style="color: #ff0000;"> make[1]: *** [install-recursive] Error 1</span><br />
<span style="color: #ff0000;"> make: *** [install-recursive] Error 1</span></p>
<p>It seems like it won&#8217;t compile on Lion. So here&#8217;s the other way.</p>
<h3>Installation with Homebrew</h3>
<p>So instead I&#8217;m installing it using H<a href="http://mxcl.github.com/homebrew/">omebrew</a> (a package installer for Mac OS), follow those <a href="https://github.com/mxcl/homebrew/wiki/installation">instructions</a> to install it.</p>
<p>Once brew is installed, run the following command:</p>
<p><span style="color: #000000;"></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ brew install gettext<br />
$ sudo brew link gettext</div></td></tr></tbody></table></div>
<p></span></p>
<p><strong>Then you MUST add that package to your path:</strong></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$echo 'export PATH=/usr/local/Cellar/gettext/0.18.1.1/bin:$PATH' &amp;gt;&amp;gt; ~/.profile</div></td></tr></tbody></table></div>
<p>* Make sure that your path is correct as well!</p>
<p>Or you will get the following error:<br />
/bin/sh: msguniq: command not found</p>
<p>We should be good to go to the next step now.</p>
<h2>Generating language files</h2>
<p>One thing the Django admin command won&#8217;t do, is creating the locale folders. So in your project directory (or app directory) add the following folder structure (one for each language):</p>
<p><a href="http://gpiot.com/wp-content/uploads/2012/06/Screen-Shot-2012-06-06-at-15.10.55.png"><img class="alignnone size-full wp-image-491" title="Screen Shot 2012-06-06 at 15.10.55" src="http://gpiot.com/wp-content/uploads/2012/06/Screen-Shot-2012-06-06-at-15.10.55.png" alt="" width="513" height="109" /></a></p>
<p>Those folder will indicate in which language your project needs to be localised. Then run the following command to generate the language files</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ django-admin.py makemessages -a</div></td></tr></tbody></table></div>
<p>This command will compile all the languages at once (for more specific command check the <a href="https://docs.djangoproject.com/en/1.4/topics/i18n/translation/">Django docs</a>).</p>
<p>So you will get something like that:</p>
<p><a href="http://gpiot.com/wp-content/uploads/2012/06/Screen-Shot-2012-06-06-at-15.33.10.png"><img class="alignnone size-full wp-image-499" title="Screen Shot 2012-06-06 at 15.33.10" src="http://gpiot.com/wp-content/uploads/2012/06/Screen-Shot-2012-06-06-at-15.33.10.png" alt="" width="466" height="206" /></a></p>
<p>The PO file contains the original translation string followed byt the translated one (French example):</p>
<p><em>#: map/forms.py:9</em><br />
<em> msgid &#8220;Hello&#8221;</em><br />
<em> msgstr &#8220;Bonjour&#8221;</em></p>
<p>Once you (or the translator) have completed all the translations in that PO file, you can run the <strong>compile command:</strong></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ django-admin.py compilemessages</div></td></tr></tbody></table></div>
<p>It will generate the compiled MO files, which will be used by Django for translating all the texts.</p>
<p><a href="http://gpiot.com/wp-content/uploads/2012/06/Screen-Shot-2012-06-06-at-15.37.18.png"><img class="alignnone size-full wp-image-502" title="Screen Shot 2012-06-06 at 15.37.18" src="http://gpiot.com/wp-content/uploads/2012/06/Screen-Shot-2012-06-06-at-15.37.18.png" alt="" width="451" height="257" /></a></p>
<p>You will have run the makemessages command everytime you had or modify transalted string in your app, then compile everytime you change the translations.</p>
<h2>Translation helper</h2>
<p>I&#8217;ve been using a great Django app to handle translation easily, called <a href="https://github.com/mbi/django-rosetta">Rosetta</a>. It will make form fields in your admin for each translation, which ease the process rather than going through a really long text file.</p>
<p>Happy translating!</p>
]]></content:encoded>
			<wfw:commentRss>http://gpiot.com/django-internationalization-on-osx-lion/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fixing a MySQL &#8220;incorrect string value&#8221; error when save unicode string</title>
		<link>http://gpiot.com/fixing-a-mysql-incorrect-string-value-error-when-save-unicode-string/</link>
		<comments>http://gpiot.com/fixing-a-mysql-incorrect-string-value-error-when-save-unicode-string/#comments</comments>
		<pubDate>Wed, 30 May 2012 16:49:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://gpiot.com/?p=475</guid>
		<description><![CDATA[I have recently been working with a CSV list of player names, which I needed to import into MySQL. Using the CSV library in Python, I managed to read and slice my csv accordingly, here is an example: 12345678910import csv [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been working with a CSV list of player names, which I needed to import into MySQL.</p>
<p>Using the CSV library in Python, I managed to read and slice my csv accordingly, here is an example:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">csv</span><br />
players = <span style="color: #dc143c;">csv</span>.<span style="color: black;">reader</span><span style="color: black;">&#40;</span><span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'media/players.csv'</span>, <span style="color: #483d8b;">'rb'</span><span style="color: black;">&#41;</span>, delimiter=<span style="color: #483d8b;">','</span>, quotechar=<span style="color: #483d8b;">'|'</span><span style="color: black;">&#41;</span><br />
i = <span style="color: #ff4500;">0</span><span style="color: #66cc66;">;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> row <span style="color: #ff7700;font-weight:bold;">in</span> players:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> row<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> i <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; player = Player.<span style="color: black;">objects</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #008000;">id</span>=i<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; player.<span style="color: black;">first_name</span> = row<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; player.<span style="color: black;">save</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; i = i+<span style="color: #ff4500;">1</span></div></td></tr></tbody></table></div>
<p>In the following example, I have already created the list of players, but some Polish characters in their name appear as &#8220;?&#8221;.</p>
<p><strong>The problem is that the column in that database table (the one for the name) hasn&#8217;t got the right encoding charset, which should be UTF-8.</strong></p>
<p>The best way to convert the column to UTF-8 is to run the following command in your mysql prompt, against the right database:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ALTER TABLE players_player MODIFY COLUMN first_name VARCHAR(255)  CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;</div></td></tr></tbody></table></div>
<p>Once you&#8217;ve done this, re-run your Python import/update script and the name should be saved with the right characters.</p>
]]></content:encoded>
			<wfw:commentRss>http://gpiot.com/fixing-a-mysql-incorrect-string-value-error-when-save-unicode-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python &#8211; Set character encoding to UTF-8</title>
		<link>http://gpiot.com/python-set-character-encoding-to-utf-8-for-deploy-cms/</link>
		<comments>http://gpiot.com/python-set-character-encoding-to-utf-8-for-deploy-cms/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 10:39:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Deploy]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://gpiot.com/?p=439</guid>
		<description><![CDATA[In Python, the default character encoding set is ASCII, limiting us to a bunch of 128 basic characters. Though, in most sites, we may use accented characters or other various symbols. So in the default Python settings, you may come [...]]]></description>
			<content:encoded><![CDATA[<p>In Python, the default character encoding set is ASCII, limiting us to a bunch of 128 basic characters. Though, in most sites, we may use accented characters or other various symbols.</p>
<p>So in the default Python settings, you may come up with an issue similar to this:</p>
<pre><strong>ascii' codec can't encode character u'\xe9' in position 3828: ordinal not in range(128)</strong></pre>
<p>The solution to this is to force Python to encode characters in UTF-8.</p>
<p>For that we need to find <em>site.py</em> on our Python path (print sys.path to find out), and add the following line right under <em>import sys, os</em>:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span><br />
<span style="color: #808080; font-style: italic;">#insert the following line</span><br />
<span style="color: #dc143c;">sys</span>.<span style="color: black;">setdefaultencoding</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'utf-8'</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>Now restart your site (if using wsgi) or else your web server, and you should be good to use all kind of utf-8 characters.</p>
]]></content:encoded>
			<wfw:commentRss>http://gpiot.com/python-set-character-encoding-to-utf-8-for-deploy-cms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django CMS &#8211; enable URL prefix (useful for proxy URLs)</title>
		<link>http://gpiot.com/django-cms-enable-url-prefix-useful-for-proxy-urls/</link>
		<comments>http://gpiot.com/django-cms-enable-url-prefix-useful-for-proxy-urls/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 17:28:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Django CMS]]></category>

		<guid isPermaLink="false">http://gpiot.com/?p=392</guid>
		<description><![CDATA[This modification is to add a URL prefix to all URLs, so all the link generated within the CMS will have that prefix automatically implemented. The reason I have implemented that change is because I had to match the URLs [...]]]></description>
			<content:encoded><![CDATA[<p>This modification is to add a URL prefix to all URLs, so all the link generated within the CMS will have that prefix automatically implemented.</p>
<p><em>The reason I have implemented that change is because I had to match the URLs from my site to URL being proxied from another server. Since the proxied URL contains extra path (.eg example.com/welcome) and my site is running under the root (eg.mysite.com), I&#8217;m adding this prefix (in that case it would be /welcome) to all my site URL so it matches the ones from the proxy.</em></p>
<p>Ok so first, we must added this setting in settings.py:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">CMS_URL_PREFIX = <span style="color: #483d8b;">'/welcome'</span></div></td></tr></tbody></table></div>
<p>Please we won&#8217;t use a slash in the end, since it&#8217;s already added by the URL resolver.</p>
<p>There are 2 areas where that prefix must be added:</p>
<h2>In cms/models/page_model.py:</h2>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">def</span> get_absolute_url<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, language=<span style="color: #008000;">None</span>, fallback=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">self</span>.<span style="color: black;">is_home</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> reverse<span style="color: black;">&#40;</span><span style="color: #483d8b;">'pages-root'</span>, prefix=settings.<span style="color: black;">CMS_URL_PREFIX</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> settings.<span style="color: black;">CMS_FLAT_URLS</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; path = <span style="color: #008000;">self</span>.<span style="color: black;">get_slug</span><span style="color: black;">&#40;</span>language, fallback<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> urlutils.<span style="color: black;">urljoin</span><span style="color: black;">&#40;</span>reverse<span style="color: black;">&#40;</span><span style="color: #483d8b;">'pages-root'</span>, prefix=settings.<span style="color: black;">CMS_URL_PREFIX</span><span style="color: black;">&#41;</span>, path<span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; path = <span style="color: #008000;">self</span>.<span style="color: black;">get_path</span><span style="color: black;">&#40;</span>language, fallback<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> urlutils.<span style="color: black;">urljoin</span><span style="color: black;">&#40;</span>reverse<span style="color: black;">&#40;</span><span style="color: #483d8b;">'pages-root'</span>, prefix=settings.<span style="color: black;">CMS_URL_PREFIX</span><span style="color: black;">&#41;</span>, path<span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>Modified line 122:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">return</span> reverse<span style="color: black;">&#40;</span><span style="color: #483d8b;">'pages-root'</span>, prefix=settings.<span style="color: black;">CMS_URL_PREFIX</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>Modified line 125:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">return</span> urlutils.<span style="color: black;">urljoin</span><span style="color: black;">&#40;</span>reverse<span style="color: black;">&#40;</span><span style="color: #483d8b;">'pages-root'</span>, prefix=settings.<span style="color: black;">CMS_URL_PREFIX</span><span style="color: black;">&#41;</span>, path<span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>Modified line 128:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">return</span> urlutils.<span style="color: black;">urljoin</span><span style="color: black;">&#40;</span>reverse<span style="color: black;">&#40;</span><span style="color: #483d8b;">'pages-root'</span>, prefix=settings.<span style="color: black;">CMS_URL_PREFIX</span><span style="color: black;">&#41;</span>, path<span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<h2>In menus/menu_pool.py:</h2>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">def</span> _mark_selected<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, request, nodes<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; sel = <span style="color: #008000;">None</span><br />
<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> node <span style="color: #ff7700;font-weight:bold;">in</span> nodes:<br />
&nbsp; &nbsp; &nbsp; &nbsp; node.<span style="color: black;">sibling</span> = <span style="color: #008000;">False</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; node.<span style="color: black;">ancestor</span> = <span style="color: #008000;">False</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; node.<span style="color: black;">descendant</span> = <span style="color: #008000;">False</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; node.<span style="color: black;">selected</span> = <span style="color: #008000;">False</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; url_to_comp = settings.<span style="color: black;">CMS_URL_PREFIX</span>+request.<span style="color: black;">path</span><span style="color: black;">&#91;</span>:<span style="color: #008000;">len</span><span style="color: black;">&#40;</span>node.<span style="color: black;">get_absolute_url</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> node.<span style="color: black;">get_absolute_url</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/'</span><span style="color: black;">&#41;</span> == url_to_comp.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/'</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> sel:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>node.<span style="color: black;">get_absolute_url</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;</span>gt<span style="color: #66cc66;">;</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>sel.<span style="color: black;">get_absolute_url</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sel = node<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sel = node<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; node.<span style="color: black;">selected</span> = <span style="color: #008000;">False</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> sel:<br />
&nbsp; &nbsp; &nbsp; &nbsp; sel.<span style="color: black;">selected</span> = <span style="color: #008000;">True</span><br />
<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> nodes</div></td></tr></tbody></table></div>
<p>Modified line 173:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">url_to_comp = settings.<span style="color: black;">CMS_URL_PREFIX</span>+request.<span style="color: black;">path</span><span style="color: black;">&#91;</span>:<span style="color: #008000;">len</span><span style="color: black;">&#40;</span>node.<span style="color: black;">get_absolute_url</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span></div></td></tr></tbody></table></div>
<p>Modified line 174:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">if</span> node.<span style="color: black;">get_absolute_url</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> == url_to_comp.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/'</span><span style="color: black;">&#41;</span>:</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://gpiot.com/django-cms-enable-url-prefix-useful-for-proxy-urls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac OS X Lion: Install the Python Image Library (PIL)</title>
		<link>http://gpiot.com/mac-os-x-lion-install-the-python-image-library-pil/</link>
		<comments>http://gpiot.com/mac-os-x-lion-install-the-python-image-library-pil/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 11:59:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development tips]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[OSX Lion]]></category>

		<guid isPermaLink="false">http://gpiot.com/?p=285</guid>
		<description><![CDATA[First make sure you have lib jpeg install for JPEG handling 123456$ curl -O http://www.ijg.org/files/jpegsrc.v8c.tar.gz $ tar zxvf jpegsrc.v8c.tar.gz $ cd jpeg-8c/ $ ./configure $ make $ sudo make install Then I use pip to install PIL 1$ sudo pip [...]]]></description>
			<content:encoded><![CDATA[<p>First make sure you have lib jpeg install for JPEG handling</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ curl -O http://www.ijg.org/files/jpegsrc.v8c.tar.gz<br />
$ tar zxvf jpegsrc.v8c.tar.gz<br />
$ cd jpeg-8c/<br />
$ ./configure<br />
$ make<br />
$ sudo make install</div></td></tr></tbody></table></div>
<p>Then I use pip to install PIL</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ sudo pip install PIL</div></td></tr></tbody></table></div>
<p>(Make sure you have Xcode installed on your machine or you may run into C compiler errors)</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://gpiot.com/mac-os-x-lion-install-the-python-image-library-pil/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>
