<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Making the internet a better place - python</title><link>http://better-inter.net/tag/python/</link><description>Torsten Engelbrecht's Blog</description><atom:link href="http://better-inter.net/rss/python/" rel="self"></atom:link><language>en</language><lastBuildDate>Sun, 17 Feb 2013 11:00:02 +0000</lastBuildDate><item><title>Migrating to Heroku</title><link>http://better-inter.net/migrating-to-heroku/</link><description>&lt;p&gt;
To cut some personal costs and simply because I was interested in it, I recently moved this blog to &lt;a href="http://www.heroku.com/" target="_blank"&gt;Heroku&lt;/a&gt;, the popular cloud hosting platform.
&lt;/p&gt;
&lt;p&gt;
Since 2011 Heroku officially supports Python deployments. Running on a single dyno it is even for free. Following the  &lt;a href="https://devcenter.heroku.com/articles/django" target="_blank"&gt;official guide to deploy a Django application&lt;/a&gt;, the transition from my VPS to Heroku was pretty straight-forward and easy. Additionally Heroku enforces good practices, like using &lt;a href="http://www.virtualenv.org/" target="_blank"&gt;virtualenv&lt;/a&gt;, and supports more and more popular technologies, like the Python WSGI server &lt;a href="http://gunicorn.org/" target="_blank"&gt;Gunicorn&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Following a short general guide of what had to be done from my side to do the transition:
&lt;/p&gt;
&lt;p&gt;
&lt;ul&gt;
&lt;li&gt;Create a fixture file from your database via the &lt;a href="https://docs.djangoproject.com/en/dev/ref/django-admin/#dumpdata-appname-appname-appname-model" target="_blank"&gt;dumpdata command&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Since I didn't want to add any billing information to Heroku yet, I had to rewrite everything related to sending emails from my web server, to save the incoming contact request in the database instead. That was pretty much just the creation of a new model and a one-liner to save it to the DB instead of sending an email,&lt;/li&gt;
&lt;li&gt;Already using virtualenv, the rest was simply adding or changing requirements. In addition of removing the MySQL bindings for python I added the following libaries:
&lt;p&gt;
&lt;pre&gt;
dj-database-url==0.2.1
django-heroku-memcacheify==0.4
django-pylibmc-sasl==0.2.4
gevent==0.13.8
greenlet==0.4.0
gunicorn==0.17.2
psycopg2==2.4.6
pylibmc==1.2.3
&lt;/pre&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
Static files are served via Django directly for the time being, since a Web-Dyno using Python can not serve them the normal way. I will move them to be served by a solution like Amazon S3 in the future. Therefore I added the following to my urlconf:
&lt;p&gt;
&lt;pre&gt;
urlpatterns += patterns(
    '',
    url(r'^media/(?P&lt;path&gt;.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
)
&lt;/pre&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
Running the dyno via Gunicorn with gevent support was a single line in the Procfile:
&lt;p&gt;
&lt;pre&gt;web: gunicorn -k gevent wsgi:application&lt;/pre&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;Finally: 
&lt;p&gt;
&lt;pre&gt;git push heroku master&lt;/pre&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;
So far I am quite happy with Heroku. I didn't recognize any differences to previous VPS hosting and I don't have to deal with server maintenance anymore, even it was an experience I don't want to miss. Goodbye VPS, welcome Heroku!
&lt;/p&gt;

 </description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Torsten</dc:creator><pubDate>Sun, 17 Feb 2013 11:00:02 +0000</pubDate><guid>http://better-inter.net/migrating-to-heroku/</guid><category>p</category><category>y</category><category>t</category><category>h</category><category>o</category><category>n</category><category>,</category><category> </category><category>d</category><category>j</category><category>a</category><category>n</category><category>g</category><category>o</category><category>,</category><category> </category><category>h</category><category>e</category><category>r</category><category>o</category><category>k</category><category>u</category></item><item><title>django-urli18n</title><link>http://better-inter.net/django-urli18n/</link><description>&lt;p&gt;Even I released django-urli18n already two weeks ago, I didn't find the time to actually announce it. So here it is:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What is django-urli18n?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A reusable Django app to display the current activated language in the URL.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;- different ways to show the language in the URL: in the path (for example www.example.com/en/home/) or in a query string (for example www.example.com/home/?lang=en)&lt;/p&gt;
&lt;p&gt;- simple to use and include into new or existing Django projects&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Where to get it?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Check out the &lt;a href="https://github.com/Torte/django-urli18n" target="_blank"&gt;project page on Github&lt;/a&gt;.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Torsten</dc:creator><pubDate>Mon, 09 May 2011 02:22:39 +0000</pubDate><guid>http://better-inter.net/django-urli18n/</guid><category>p</category><category>y</category><category>t</category><category>h</category><category>o</category><category>n</category><category>,</category><category> </category><category>d</category><category>j</category><category>a</category><category>n</category><category>g</category><category>o</category><category>,</category><category> </category><category>a</category><category>p</category><category>p</category><category>s</category></item></channel></rss>