<?xml version="1.0" encoding="utf-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:dc="http://purl.org/dc/elements/1.1/"
      xml:base="http://reinout.vanrees.org/weblog//atom.xml" xml:lang="en">
  <link rel="self"
        href="http://reinout.vanrees.org/weblog/pythonfeed.xml" />
  <link href="http://reinout.vanrees.org/weblog/"
        rel="alternate" type="text/html" />

  <div xmlns="http://www.w3.org/1999/xhtml">
    <a href="http://www.atomenabled.org/feedvalidator/check.cgi?url=http://reinout.vanrees.org/weblog//atom.xml">
      <img title="Validate my Atom feed" width="88"
           height="31"
           src="http://www.atomenabled.org/feedvalidator/images/valid-atom.png"
           alt="[Valid Atom]" border="0px" />
    </a>
    <p>
      <span>
        This is an Atom formatted XML site feed. It is intended to be viewed in
        a Newsreader or syndicated to another site. Please visit
      </span>
      <a href="http://www.atomenabled.org/">Atom Enabled</a>
      <span>
        for more info.
      </span>
    </p>
  </div>

  <title type="html">Reinout van Rees' weblog</title>
  <subtitle>Python, grok, books, history, faith, etc.</subtitle>
  <updated>2009-04-04T21:44:00+01:00</updated>
  <id>urn:syndication:a55644db8591c020bd38852775819a9a</id>

  
  <entry>
    <title>Python and Django job in Utrecht</title>
    <link rel="alternate" type="text/html"
          href="http://reinout.vanrees.org/weblog/2010/08/24/python-django-vacature-utrecht.html" />
      <id>http://reinout.vanrees.org/weblog//weblog/2010/08/24/python-django-vacature-utrecht.html</id>
      <author>
        <name>Reinout van Rees</name>
      </author>
      <published>2010-08-24T00:00:00+01:00</published>
      <updated>2010-08-23T23:54:00+01:00</updated>

      
      <category term="python" />
      
      <category term="django" />
      

      <content type="xhtml"
               xml:base="http://reinout.vanrees.org/weblog/"
               xml:lang="en-US"
               xml:space="preserve">
        <div xmlns="http://www.w3.org/1999/xhtml">
          <div class="document">
<p>Summary: yep, we (<a class="reference external" href="http://www.nelen-schuurmans.nl">Nelen &amp; Schuurmans</a>) need
a new Python/Django programmer!  Location: Utrecht, the Netherlands, right in
the center of town.  The work subject?  Geodjango and water management: that's
the shortest summary.</p>
<p>Five months ago I wrote about an <a class="reference external" href="http://reinout.vanrees.org/weblog/2010/03/23/django-vacature-utrecht.html">upcoming job opening</a>.
We got, if I remember correctly, nine reactions, eight of which mentioned
&quot;yeah, I saw on Reinout's blog/twitter...&quot;.  The power of twitter and blogs
wasn't demonstrated <em>that</em> vividly to my colleages yet :-) The end effect was
that when we invited people to come round for a talk, they were introduced
internally as &quot;oh, some of Reinout's friends are coming&quot;...  That meant I had
some explaining to do during lunch :-)</p>
<p>Business is booming and there's yet another big project coming our way.
<strong>Help!</strong> We really need to crank up the output.  At the moment we're three
people doing the practical day-to-day Django coding with another one coming up
in a week.  Cooperative, productive, friendly.  We could really use another
pair of hands (and a brain, of course).</p>
<ul class="simple">
<li>Django experience?  Not needed per se, Django is friendly and modular enough
that we can teach you.  But on the other hand, we really want to get
cracking turning out new websites!</li>
<li>Bonus points if you're any good in html/css/javascript.  If I tell former
colleague (and css wizard) <a class="reference external" href="http://zestsoftware.nl/over/team/mirella">Mirella</a> that I'm now the local number
one css expert, she'll probably laugh out loud.  I'm not bad at all, but a
bit of extra knowledge won't hurt.  That reminds me: I've got to interrogate
our new colleague on his level of css knowledge...</li>
<li>We want good software.  As an illustration, I've set up a <a class="reference external" href="https://hudson.dev.java.net/">Hudson</a> continuous integration server to monitor
the tests, code coverage and the pep8/pyflakes score.  We really need to get
our act together to get our code coverage up to percentages that I dare
mention here.</li>
<li>Packaging, automation, buildout, hudson, deployment: we've got that one
right.  Lots of automation.  Buildout helps a lot.  Repeatable.  Deployments
are boring (as they should be) as they're mostly flawless.</li>
<li>Windows experience would be helpful as we sometimes need to <a class="reference external" href="http://reinout.vanrees.org/weblog/2010/08/18/geodjango-windows.html">deploy on
windows</a>. In
practice all three (and soon four) of us Django programmers are on
<strong>Ubuntu</strong>.</li>
</ul>
<p>The timeframe?  What I heard is a closing date of 23 September.  But we might
start inviting people over sooner as there <em>really</em> are a couple of projects
lining up.  So don't wait too long.</p>
<p>The official stuff?  The official <a class="reference external" href="http://www.nelen-schuurmans.nl/NL/bedrijfsprofiel/carriere/8">vacature</a> is on our
website.  Yep, that's in Dutch.  I'm afraid that speaking Dutch is handiest to
get settled into the company.  We might be open for an experiment, though :-)</p>
<p>You can always <a class="reference external" href="mailto:reinout&#64;vanrees.org">mail me</a> if you've got further
questions, of course.</p>
<a class="reference external image-reference" href="http://photos.reinout.vanrees.org/Grok-zope-plone-python/nelen-schuurmans/11586589_cibu3#980236336_7xFba-A-LB"><img alt="Company outing in Utrecht" src="http://photos.reinout.vanrees.org/photos/980236336_7xFba-M.jpg" /></a>
</div>

        </div>
      </content>

    </entry>
    
  <entry>
    <title>Simplejson, python2.6 and windows</title>
    <link rel="alternate" type="text/html"
          href="http://reinout.vanrees.org/weblog/2010/08/19/simplejson-windows.html" />
      <id>http://reinout.vanrees.org/weblog//weblog/2010/08/19/simplejson-windows.html</id>
      <author>
        <name>Reinout van Rees</name>
      </author>
      <published>2010-08-19T00:00:00+01:00</published>
      <updated>2010-08-19T19:16:00+01:00</updated>

      
      <category term="django" />
      

      <content type="xhtml"
               xml:base="http://reinout.vanrees.org/weblog/"
               xml:lang="en-US"
               xml:space="preserve">
        <div xmlns="http://www.w3.org/1999/xhtml">
          <div class="document">
<p>There was one additional problem I saw with <a class="reference external" href="http://reinout.vanrees.org/weblog/2010/08/18/geodjango-windows.html">yesterday's windows installation</a>:
simplejson!</p>
<p>Totally unexpected.  The good thing is that simplejson is shipped with python
2.6 and higher.  The sane thing is that they named it &quot;json&quot; instead of
&quot;simplejson&quot;.</p>
<p>The bad or at least unexpected thing: I cannot find a windows installer for
simplejson for python 2.6!  Which means my &quot;import simplejson&quot; won't work
anymore.  And those have to be in as the software gets installed on python 2.5
sometimes.</p>
<p>For windows + python 2.6 compatibility I now have the following in at least 10
different files:</p>
<pre class="literal-block">
try:
    import json  # Python 2.6+
except ImportError:
    import simplejson as json  # Python 2.5-
</pre>
<p>And I've had to remove simplejson as a dependency.  I don't yet know a good
solution for that.  I don't think you can have an optional dependency based on
the python version with the current distribute/setuptools.  Of course you
could do some more if/else trickery in there as a <cite>setup.py`</cite> is just a python
file after all.</p>
<p>Anyone got a good hint?  Is there something I overlooked?</p>
</div>

        </div>
      </content>

    </entry>
    
  <entry>
    <title>Windows installation went OK</title>
    <link rel="alternate" type="text/html"
          href="http://reinout.vanrees.org/weblog/2010/08/19/windows-installation.html" />
      <id>http://reinout.vanrees.org/weblog//weblog/2010/08/19/windows-installation.html</id>
      <author>
        <name>Reinout van Rees</name>
      </author>
      <published>2010-08-19T00:00:00+01:00</published>
      <updated>2010-08-19T19:38:00+01:00</updated>

      
      <category term="django" />
      

      <content type="xhtml"
               xml:base="http://reinout.vanrees.org/weblog/"
               xml:lang="en-US"
               xml:space="preserve">
        <div xmlns="http://www.w3.org/1999/xhtml">
          <div class="document">
<p>My (geo)django installation on the customer's windows 2008 box went way better
than I expected.  &quot;Mostly smooth&quot; is what I'd call it.  My windows experience
is a tad rusty after not using windows productively for about 13 years or so.
And I ran into all sorts of problems when trying it out locally.  So I
expected much worse.</p>
<p>Trying everything out beforehand and assembling the right set of packages and
killing off all DLL problems helps.  See my <a class="reference external" href="http://reinout.vanrees.org/weblog/2010/08/18/geodjango-windows.html">earlier article about all the
weird problems I encountered</a>). It
is hard work to find the cause for some obscure DLL problem, but it beats
having to debug it when the customer is sitting next to you :-)</p>
<p>The actual installation went without a hitch.  Everything installed just
fine.  I had written down what I had to do beforehand: that paid out in
spades.  I only saw two serious problems in the end:</p>
<ul class="simple">
<li>Oracle doesn't like django's TextFields when they're used with an
<tt class="docutils literal"><span class="pre">.distinct()</span></tt> query.  They also cannot be used for indexes or primary
keys.  Oracle stores them as a &quot;NCLOB&quot; field: some sort of character blob.
I fixed the one part in the code where I had a <tt class="docutils literal"><span class="pre">.distinct()</span></tt>: no, that
didn't help.  In the end a &quot;name&quot; field (the most important field in the
model) was a TextField instead of a CharField just like all the other
models...  Ok, that's a regular bug in our code.  And <em>another reminder that
all our code needs to be tested</em>: we'd have caught this bug for sure in that
case.</li>
<li>Apache seems to die after a while.  Apache with a django-behind-mod_wsgi
setup.  I got the impression it died after some 100 requests.  But during
the last test it seemed to die instantly.  Every request seems to have no
effect after the &quot;crash&quot; or whatever it is: there's no clear error message.
Every request just seems to disappear in a black hole.  I'll have to google
that one, as I couldn't figure it out in time.</li>
</ul>
<p>In any case: the software installed just fine.  And the oracle database
connection works just fine.  And the customer was happy!  And I'm too :-)</p>
</div>

        </div>
      </content>

    </entry>
    
  <entry>
    <title>Geodjango with oracle on windows: surprises and fixes</title>
    <link rel="alternate" type="text/html"
          href="http://reinout.vanrees.org/weblog/2010/08/18/geodjango-windows.html" />
      <id>http://reinout.vanrees.org/weblog//weblog/2010/08/18/geodjango-windows.html</id>
      <author>
        <name>Reinout van Rees</name>
      </author>
      <published>2010-08-18T00:00:00+01:00</published>
      <updated>2010-08-18T20:44:00+01:00</updated>

      
      <category term="django" />
      
      <category term="gis" />
      

      <content type="xhtml"
               xml:base="http://reinout.vanrees.org/weblog/"
               xml:lang="en-US"
               xml:space="preserve">
        <div xmlns="http://www.w3.org/1999/xhtml">
          <div class="document">
<p>One of our customers demanded a windows installation of his geodjango
application.  None of our active developers are well versed in that.  My last
personal well-maintained windows installation was <strong>windows 3.1</strong>.  There.</p>
<p>So I spend two days getting it working on a temporary windows 2008 test
machine and on a local virtualbox.  Those were two days I'd rather been
spending on some productive coding, to be honest.  Finding problems and
solving them have their own merit and <em>somebody</em> needs to so it so I girded
myself and got down to work.  I'll list some of the bad and good things below,
including solutions.</p>
<div class="section" id="actual-django-project-well-deployable">
<h1>Actual Django project: well-deployable</h1>
<p>I did not have to worry about the actual Django project we were shipping.
We're using buildout to make our builds and deployments <a class="reference external" href="http://reinout.vanrees.org/weblog/2010/04/14/buildout.html">repeatable</a>.  On a regular
ubunbu box, deploying a new site is a non-event: easy as pie and faultless,
mostly.  You know which &quot;aptitude install&quot; commands to run to get the external
dependencies.  And buildout grabs all the regular python packages you
specified and prepares the Django instance, apache config and all the rest.</p>
<p>Buildout works the same on windows: it grabs all the stuff and configures
everything I told it to configure.  And as I created the project from <a class="reference external" href="http://reinout.vanrees.org/weblog/2010/07/30/skeleton.html">our
internal skeleton/code template</a>, it came out of
the box with that at-least-working apache config for windows I distilled from
the last windows project.  Happy.</p>
<p>Problem: <strong>no internet access on the server</strong>.  Intranet.  Well-protected.  So
I need to bring a CD with all the code.  Easy to do with buildout if you use
<a class="reference external" href="http://pypi.python.org/pypi/zc.sourcerelease">zc.sourcerelease</a>.  The
documentation isn't clear, but once you installed zc.sourcerelease somewhere,
you can call <tt class="docutils literal"><span class="pre">bin/buildout-source-release</span>
<span class="pre">https://url/to/your/project/tags/1.7</span> <span class="pre">buildout.cfg</span></tt>.  So the url is your svn
url.  That works best in my experience.  And the second parameter is the
buildout config (in our case <tt class="docutils literal"><span class="pre">deploy.cfg</span></tt> as that's the production config).
And give it a <tt class="docutils literal"><span class="pre">-n</span> <span class="pre">project-1.7</span></tt> parameter to get a better name than <tt class="docutils literal"><span class="pre">1.7</span></tt>.</p>
<p>The result is: <tt class="docutils literal"><span class="pre">project-1.7.tgz</span></tt>.  Your complete buildout including all the
eggs and downloads it would otherwise have to grab from the internet.  Extract
it and run <tt class="docutils literal"><span class="pre">python</span> <span class="pre">install.py</span></tt> (instead of the normal <tt class="docutils literal"><span class="pre">python</span>
<span class="pre">bootstrap.py</span></tt> and <tt class="docutils literal"><span class="pre">bin/buildout</span></tt> calls).  Ready.  Wow.</p>
</div>
<div class="section" id="installing-installing">
<h1>Installing, installing</h1>
<p>Installing on windows starts easy.  I looked at the geodjango install page
and ask a colleague for the set of .exe and .zip files from his last windows
deployment.  Ok: <tt class="docutils literal"><span class="pre">python-2.6.4.exe</span></tt> and double-click.  Same for apache.  And
matplotlib.  And numpy.  And an oracle connector.</p>
<p>And lxml: ouch, the latest version doesn't have a python2.6 installer!  I
found a slightly older one that did.  Another problem solved.</p>
<p>Some stuff is different.  Some oracle &quot;instantclient&quot; (a set of DLLs) must be
placed in some directory that you then add to the system path.  Same with
mapnik.</p>
<p>And the apache mod_wsgi module is shipped as a <tt class="docutils literal"><span class="pre">.so</span></tt> file that you have to
copy somewhere deep in apache's directory structure.  Manually.</p>
<p>Ok, fine so far.  Let's fire up apache.  Boom.  Ok, let's try django itself on
the terminal.  Boom.  Uh oh...</p>
</div>
<div class="section" id="cx-oracle-dll-problem">
<h1>cx_Oracle DLL problem</h1>
<p>When firing up django, it would complain that it couldn't load the oracle
database connector.  Some dll had a hickup.  <a class="reference external" href="http://www.dependencywalker.com/">Dependencywalker</a> is a great, simple tool that inspects a
DLL for you and tells you which DLLs that it depends on are missing.  I don't
remember whether it was linkinfo.dll or msvcr90.dll or msvcr71.dll anymore.
The last two are redistributable files from microsoft visual studio.  You can
actually grab a .exe installer for them.  Only, which of them?  The 2008 or
the 2009 or 2010?  It doesn't say which one includes which number...</p>
<p>I'm actually not sure anymore what solved this issue.  I installed at least
two of those redistributable file installers.  And I swapped around between an
oracle 10 and 11 connector and matching &quot;instantclient&quot; libraries.  I think
the 11 one worked in the end.  I sure hope it goes well on the client's
server!</p>
</div>
<div class="section" id="oracle-geodjango-geos-dll-problem">
<h1>Oracle/geodjango GEOS DLL problem</h1>
<p>Geodjango depends on the <a class="reference external" href="http://trac.osgeo.org/geos/">GEOS</a> library.  Also
in combination with oracle.   When trying to connect to the spatial database,
I'd get an <em>ImproperlyConfigured: Could not import user-defined
GEOMETRY_BACKEND &quot;geos&quot;.</em> error.  Well, that's just another library to
install, right?</p>
<p>Problem: there's no windows installer for geos.  Only compile instructions.
What?  Can't be true.  So I asked around on two mailinglists and on irc and
got great help.  What the situation is?</p>
<ul class="simple">
<li>Use the geodjango windows installer.  It installs django, but you can ignore
that (just zap the <tt class="docutils literal"><span class="pre">django.pth</span></tt> from your site-packages directory).  It
also installs the Proj projection files (ok, I already installed those by
hand, but that's fine anyway).  It installs gdal (good thing as I almost
forgot that one).  The gdal install also included <em>some geos .so</em>.
Unfortunately, that's not enough.</li>
<li>Incredible when you want to use a remote oracle database: you need to
<strong>install postgresql and postgis</strong>.  Say again?  Yes, to get the geos
libraries you need to install postgis.  You can probably copy/paste some
DLLs around, but I thought it safer to just install the whole thing
cleanly.</li>
</ul>
</div>
<div class="section" id="matplotlib-dll-problem">
<h1>Matplotlib DLL problem</h1>
<p>Next DLL problem on the list: matplotlib.  After <em>finally</em> getting over the
oracle + geo database hurdle, I could really start up Django.  Only to have it
die almost instantly once a graph had to be shown.  Without a clear error
message:</p>
<pre class="literal-block">
from matplotlib._path import affine_transform
ImportError: DLL load failed: The specified module could not be found
</pre>
<p>Well, which DLL?!?  I had to go into the source code to get it to print a
better error message.  The ImportError exception was silently swallowed and a
different import tried which also failed with a different error... The real
error message gave me more information about which DLL was missing.</p>
<p>Dependencywalker to the rescue again.  This DLL was missing a
<tt class="docutils literal"><span class="pre">linkinfo.dll</span></tt>.  Another one of those microsoft DLLs.  Not available,
though.  And googling it gives a metric ton of virus links and warnings.</p>
<p>Some more googling showed that more recent matplotlib releases were compiled
in a more reliable way with ms visual studio instead of the mingw compiler.
So I grabbed a 1.0.0 release which even worked.</p>
</div>
<div class="section" id="pil-problems">
<h1>PIL problems</h1>
<p>The python imaging library isn't clear on how it is supposed to be imported.
&quot;import Image&quot;, &quot;import PIL.Image&quot;, &quot;from PIL import Image&quot;.  You see all of
them.  But that's apparently a problem on windows!</p>
<p>Python (and even apache plus mod_wsgi) completely died with a <tt class="docutils literal"><span class="pre">AccessInit:</span>
<span class="pre">hash</span> <span class="pre">collision:</span> <span class="pre">3</span> <span class="pre">for</span> <span class="pre">both</span> <span class="pre">1</span> <span class="pre">and</span> <span class="pre">1</span></tt> error message.  It <a class="reference external" href="http://jaredforsyth.com/blog/2010/apr/28/accessinit-hash-collision-3-both-1-and-1/">turned out to be PIL</a>.
&quot;Image&quot; and &quot;PIL.Image&quot; are the same object, but with a different name.  I
have no idea why this would be different between windows and unix, but
whatever.</p>
<p>The solution is to put this hack in your django's <tt class="docutils literal"><span class="pre">settings.py</span></tt> (see the
comments on that <a class="reference external" href="http://jaredforsyth.com/blog/2010/apr/28/accessinit-hash-collision-3-both-1-and-1/">article linked above</a>:</p>
<pre class="literal-block">
import sys
import PIL.Image
sys.modules['Image'] = PIL.Image
</pre>
</div>
<div class="section" id="conclusion">
<h1>Conclusion</h1>
<ul class="simple">
<li>Even when starting with a brand new windows install, you can still run into
DLL hell.</li>
<li>Expect unexpected weirdness.</li>
<li>Reliably compiling for windows is hard, especially when you depend on a lot
of things.</li>
<li>Don't complain toooooooo hard.  Get to work.  It needs doing, sadly.</li>
<li>Buildout and zc.sourcerelease work just fine.  They're a island of
tranquility in a sea of muck.</li>
</ul>
</div>
</div>

        </div>
      </content>

    </entry>
    
  <entry>
    <title>Combining css and javascript in Django</title>
    <link rel="alternate" type="text/html"
          href="http://reinout.vanrees.org/weblog/2010/08/04/django-css-js-compressor.html" />
      <id>http://reinout.vanrees.org/weblog//weblog/2010/08/04/django-css-js-compressor.html</id>
      <author>
        <name>Reinout van Rees</name>
      </author>
      <published>2010-08-04T00:00:00+01:00</published>
      <updated>2010-08-04T08:21:00+01:00</updated>

      
      <category term="django" />
      

      <content type="xhtml"
               xml:base="http://reinout.vanrees.org/weblog/"
               xml:lang="en-US"
               xml:space="preserve">
        <div xmlns="http://www.w3.org/1999/xhtml">
          <div class="document">
<p>I'm handling <a class="reference external" href="http://reinout.vanrees.org/weblog/2010/05/19/django-css-javascript-files.html">Django and css/javascript files</a>
with <a class="reference external" href="http://pypi.python.org/pypi/django-staticfiles">django-staticfiles</a>.
This makes it easy to ship javascript and css files (and images) with your
Django applications.</p>
<p>The end result, for me, is quite a number of css and javascript files.</p>
<ul class="simple">
<li>Blueprint css framework has two css files.</li>
<li>Jquery; jquery ui; openflow jquery tools; openlayers.  All javascript files.</li>
<li>A jquery tree extention and one or two that I've forgotten about.</li>
<li>Two or three reusable apps, each with a css and js file.</li>
</ul>
<p>Ehm?  That's not good for the responsiveness of the website, as it increases
the number of server requests that need to happen.  And the number of requests
is nowadays often a big percentage of the time it takes to load a page.</p>
<p>The basic solution: combine the javascript and css files into one javascript
and one css file.  (Well, css files need to be split a bit according to their
<tt class="docutils literal"><span class="pre">media=&quot;screen,</span> <span class="pre">presentation&quot;</span></tt> or <tt class="docutils literal"><span class="pre">media=&quot;print&quot;</span></tt> settings).</p>
<p>There are a number of Django solutions.  I went with <a class="reference external" href="http://pypi.python.org/pypi/django_compressor">django_compressor</a> as I found a <a class="reference external" href="http://dpaste.de/xLDU/">snippet of
code</a> that showed how to integrate django_compressor
with django-staticfiles.  (Warning as I made that mistake: one has an
underscore, one has a dash in the name...)</p>
<p>The basic usage in templates is simple.  I'm using a <a class="reference external" href="http://pypi.python.org/pypi/lizard-ui">custom base UI django
application</a> for all our websites
with a base template.  I just had to add django_compressor's statement in
there around my css/js blocks and I was done:</p>
<pre class="literal-block">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;
      {% block title %}
      Sample title
      {% endblock title %}
    &lt;/title&gt;
    {% load compress %}
    {% compress css %}
    {% block css %}
    {# Blueprint css framework. #}
    &lt;link rel=&quot;stylesheet&quot;
          href=&quot;{{ STATIC_URL }}blueprint/screen.css&quot;
          type=&quot;text/css&quot;
          media=&quot;screen, projection&quot; /&gt;
    &lt;link type=&quot;text/css&quot;
          href=&quot;{{ STATIC_URL }}jquery-treeview/jquery.treeview.css&quot;
          rel=&quot;stylesheet&quot;
          media=&quot;screen, projection&quot; /&gt;
    &lt;!-- And a couple of other stylesheets, of course --&gt;
    {% endblock css %}
    {% endcompress %}

    {% compress js %}
    {% block javascript %}
    &lt;script type=&quot;text/javascript&quot;
            src=&quot;{{ STATIC_URL }}jquery/jquery.js&quot;&gt;&lt;/script&gt;
    &lt;!-- Yeah, and more js, of course --&gt;
    {% endblock javascript %}
    {% endcompress %}
    ...
</pre>
<p>And in the <tt class="docutils literal"><span class="pre">settings.py</span></tt>:</p>
<pre class="literal-block">
# Storage engine to be used during compression
COMPRESS_STORAGE = &quot;staticfiles.storage.StaticFileStorage&quot;
# The URL that linked media will be read from and compressed
# media will be written to.
COMPRESS_URL = STATIC_URL
# The absolute file path that linked media will be read from
# and compressed media will be written to.
COMPRESS_ROOT = STATIC_ROOT
</pre>
<p>Note that all three statements depend on the django-staticfiles setup.</p>
<p>Bonus for django_compressor: it not only combines the js/css, but it also
gives the static file that it generates a unique name that depends on the
timestamp of all the combined resources.  So every time something changes in
one of the source files, a new combined file with a new name is generated.  So
you can cache it forever.  This means that your users will only have to
download one css and one js file <strong>once</strong>, basically.  A huge performance
boost.</p>
<p>A bit of simple apache config that I added for this caching:</p>
<pre class="literal-block">
&lt;Location /static_media/&gt;
  # This is the regular django-staticfiles directory.
  # I set caching for one day here.  That works well enough
  # with our update frequency at the moment.
  ExpiresActive On
  ExpiresDefault &quot;access plus 1 day&quot;
&lt;/Location&gt;

&lt;Location /static_media/CACHE/&gt;
  # This is the location where django_compressor places
  # the combined files it generates.  Every one of them
  # can be cached till the day the coyote finally catches
  # the roadrunner.
  ExpiresActive On
  ExpiresDefault &quot;access plus 10 years&quot;
&lt;/Location&gt;
</pre>
<p>(You can get much more fancy with varnish caching and more cache control
headers, but this works well enough for now.  I'm all ears for better setups,
though :-)</p>
<p>Side note: using django_compressor means a bit of settings.py boilerplate in
your projects.  And some apache config boilerplate.  Why don't you make it
easy for yourself and read up on what I wrote about <a class="reference external" href="http://reinout.vanrees.org/weblog/2010/07/30/skeleton.html">software skeletons</a> for easy
creation of all your boilerplate?</p>
</div>

        </div>
      </content>

    </entry>
    
  <entry>
    <title>New checkoutmanager releases</title>
    <link rel="alternate" type="text/html"
          href="http://reinout.vanrees.org/weblog/2010/08/04/checkoutmanager_new_release.html" />
      <id>http://reinout.vanrees.org/weblog//weblog/2010/08/04/checkoutmanager_new_release.html</id>
      <author>
        <name>Reinout van Rees</name>
      </author>
      <published>2010-08-04T00:00:00+01:00</published>
      <updated>2010-08-04T19:47:00+01:00</updated>

      
      <category term="python" />
      
      <category term="django" />
      

      <content type="xhtml"
               xml:base="http://reinout.vanrees.org/weblog/"
               xml:lang="en-US"
               xml:space="preserve">
        <div xmlns="http://www.w3.org/1999/xhtml">
          <div class="document">
<p>I released <a class="reference external" href="http://pypi.python.org/pypi/checkoutmanager">checkoutmanager</a>
three days ago.  An easy tool for managing all your svn/hg/bzr/git checkouts.
After <a class="reference external" href="http://reinout.vanrees.org/weblog/2010/08/02/checkoutmanager.html">mentioning it on my blog</a>, I got
quite some positive reactions, bug reports and feature requests.  Yeah!  Nice
to see that it's useful!</p>
<p>Bug reports and feature requests mean I got to make some <strong>changes and fixes
and new releases</strong>, of course :-) So 1.1 and 1.2 are out.  Some of the bigger
changes:</p>
<ul class="simple">
<li>It works on windows now.</li>
<li>Better initial experience by printing the sample config file if you don't
have it yet.  And updated the documentation to make it clearer.  (Seeing a
colleage install it is often instructional!)</li>
<li>Added a -v/--verbose option that prints the commands and the directory where
you execute them.  Handy if you want to know exactly what's happening.</li>
<li>I'm checking the exit code of all executed commands.  When there's an error,
the command and working directory are printed and also the output.  And the
script stops right away.  Errors (mostly svn conflict errors) could go
unnoticed otherwise).</li>
</ul>
</div>

        </div>
      </content>

    </entry>
    
  <entry>
    <title>Easily juggle all your checkouts: checkoutmanager</title>
    <link rel="alternate" type="text/html"
          href="http://reinout.vanrees.org/weblog/2010/08/02/checkoutmanager.html" />
      <id>http://reinout.vanrees.org/weblog//weblog/2010/08/02/checkoutmanager.html</id>
      <author>
        <name>Reinout van Rees</name>
      </author>
      <published>2010-08-02T00:00:00+01:00</published>
      <updated>2010-08-02T16:43:00+01:00</updated>

      
      <category term="python" />
      
      <category term="django" />
      

      <content type="xhtml"
               xml:base="http://reinout.vanrees.org/weblog/"
               xml:lang="en-US"
               xml:space="preserve">
        <div xmlns="http://www.w3.org/1999/xhtml">
          <div class="document">
<p>(<strong>Update</strong>: it works on windows, too, now: 1.1 is out)</p>
<p>All my life is stored in version control, basically.  Several django
applications, several websites, some personal stuff, my PhD thesis: everything
is in subversion/mercurial/bzr/git.  I just counted them: I've got <strong>86
checkouts</strong> at the moment :-)</p>
<p>Doing an &quot;svn up&quot; or &quot;hg pull -u&quot; in all of them is boring.  And re-building
the whole set of checkouts on a fresh machine is hell.  And I knew I was about
to be changing jobs at the end of 2009.  Which meant a change of laptop.
Which meant I wrote a small program to manage my checkouts: <a class="reference external" href="http://pypi.python.org/pypi/checkoutmanager">checkoutmanager</a>.  A simple <strong>easy_install
checkoutmanager</strong> is enough to install it.</p>
<p>The basis is a <tt class="docutils literal"><span class="pre">~/.checkoutmanager.cfg</span></tt> configuration file:</p>
<pre class="literal-block">
# Sample config file.  Different sections per base location
# and version control system.  Splitting everything all over
# the place in multiple directories is fine.

[recipes]
# Buildout recipes I work on.
vcs = svn
basedir = ~/svn/recipes
checkouts =
    svn://svn/blablabla/trunk
    svn://svn/another/trunk differentname
    http://host/yetanother/trunk
    https://host/yetanother/branches/reinout-fix

[dotfolders]
# Folders that end up as dotted configfolders in the root.
# Note that there's a directory name behind the repository
# location, separated by a space.
vcs = bzr
basedir = ~
checkouts =
    lp:emacsconfig/trunk .emacs.d
    sftp://somwhere/subversion/trunk .subversion
</pre>
<p>So you've got a couple of sections.  Every section has a base directory where
everything is placed.  And a version control system: so one vcs per
directory.  And a couple of repository locations.</p>
<p>What I normally do every morning when I get to work is <tt class="docutils literal"><span class="pre">checkoutmanager</span>
<span class="pre">up</span></tt>.  This grabs the latest versions of all my checkouts from the server(s).
So an <tt class="docutils literal"><span class="pre">svn</span> <span class="pre">up</span></tt> for my subversion checkouts, a <tt class="docutils literal"><span class="pre">hg</span> <span class="pre">pull</span> <span class="pre">-u</span></tt> for mercurial
and so on.</p>
<p>From time to time, I'll do a <tt class="docutils literal"><span class="pre">checkoutmanager</span> <span class="pre">st</span></tt> to show if I've got some
uncommitted files lying around somewhere.  Very handy if you've worked in
several directories throughout the day: it prevents you from forgetting to
check in that one bugfix for a whole week.</p>
<p>A new project means I add a single line to my config file and run
<tt class="docutils literal"><span class="pre">checkoutmanager</span> <span class="pre">co</span></tt>.</p>
<p>Checkoutmanager allows you to spread your checkouts over multiple
directories.  It cannot mix version control systems per directory, however.
As an example, I've got a <tt class="docutils literal"><span class="pre">~/buildout/</span></tt> directory with my big svn website
projects checked out there.  And a directory with my svn work python
libraries.  And a <tt class="docutils literal"><span class="pre">~/hg/</span></tt> dir with my mercurial projects.  And I've made
checkouts of several config directories in my home dir, such as
<tt class="docutils literal"><span class="pre">~/.emacs.d</span></tt>, <tt class="docutils literal"><span class="pre">~/.subversion</span></tt> and so on.  Works just fine.</p>
<p>I'm real happy with checkoutmanager.  It is simple and it works.  What more
can you ask for?  So I invite you to try it.  Just run &quot;checkoutmanager&quot; and
you'll get a full explanation and even a sample config file.</p>
</div>

        </div>
      </content>

    </entry>
    
  <entry>
    <title>Software releases 6: skeletons for easy best practices</title>
    <link rel="alternate" type="text/html"
          href="http://reinout.vanrees.org/weblog/2010/07/30/skeleton.html" />
      <id>http://reinout.vanrees.org/weblog//weblog/2010/07/30/skeleton.html</id>
      <author>
        <name>Reinout van Rees</name>
      </author>
      <published>2010-07-30T00:00:00+01:00</published>
      <updated>2010-07-30T09:24:00+01:00</updated>

      
      <category term="python" />
      
      <category term="softwarereleasesseries" />
      
      <category term="buildout" />
      
      <category term="django" />
      

      <content type="xhtml"
               xml:base="http://reinout.vanrees.org/weblog/"
               xml:lang="en-US"
               xml:space="preserve">
        <div xmlns="http://www.w3.org/1999/xhtml">
          <div class="document">
<p>This is the last post in my <a class="reference external" href="http://reinout.vanrees.org/weblog/tags/softwarereleasesseries.html">software releases series</a> (at
least, the last as I originally planned the series).</p>
<p>In the last 5 articles, you've seen a couple of places where there's some
irritating boilerplate.  What's supposed to go into your <tt class="docutils literal"><span class="pre">setup.py</span></tt>?  How
did you start off with a <tt class="docutils literal"><span class="pre">buildout.cfg</span></tt> again?  Oh, don't forget the
<tt class="docutils literal"><span class="pre">CHANGES.txt</span></tt> and a basic <tt class="docutils literal"><span class="pre">README.txt</span></tt>.  The solution for that is
something I normally call a <strong>skeleton</strong>.  I mentioned skeletons earlier in a
Dutch python user group talk on <a class="reference external" href="http://reinout.vanrees.org/weblog/2009/05/28/practical-project-automation.html">practical project automation</a>.</p>
<p>A skeleton is a basic project structure with a README, a couple of
directories, some python files to start off with and whatever else you want to
put in there.  You give it some parameters (project name, website address,
whatever) and it'll fill in the blanks with those parameters.</p>
<p>Django has a <tt class="docutils literal"><span class="pre">manage.py</span> <span class="pre">startapp</span></tt>, but there's a generic python tool called
<a class="reference external" href="http://pypi.python.org/pypi/PasteScript">PasteScript</a>.  PasteScript's
documentation almost exclusively talks about running wsgi applications, but it
actually can create project skeletons for you.  The best way to get started is
to look at <a class="reference external" href="http://pypi.python.org/pypi/ZopeSkel">ZopeSkel</a>, which has a
large collection of skeletons.  Download it and see what it can do.</p>
<p>There are <strong>two core advantages</strong> to using skeletons either for yourself or
within your community or within your company:</p>
<ul class="simple">
<li><strong>Boilerplate reduction</strong>.  Basic files get created and set up for you.
Laziness works to your advantage.  &quot;Just start the project from a skeleton&quot;
gives you something reasonably solid and neat.  The alternative is to just
start off with a python file and a sub directory and &quot;remember&quot; to add the readme
and so later.</li>
<li><strong>Best practice</strong>.  Pour your knowledge into a skeleton.  Figure out the way
you want to set up your projects once and reap the fruits many times over.
You're probably copy-pasting apache config files from one project to the
other: why not keep the latest and greatest config file in the skeleton?
For me, this is the number one advantage: <em>you've got a place to collect
your project setup best practice</em>.  And having that place to put it means
that more best practice gets attracted!</li>
</ul>
<p>Want to start your own skeleton?  What I'd recommend is to start with a
<a class="reference external" href="http://pypi.python.org/pypi/ZopeSkel">ZopeSkel</a> download and to look at
their code and how to set it all up.  Then start your own.  I worked for <a class="reference external" href="http://zestsoftware.nl/">Zest
software</a> and started &quot;zestskel&quot; there.  I worked
for <a class="reference external" href="http://www.thehealthagency.com/">The Health Agency</a> afterwards and
started &quot;thaskel&quot; there.  Now I work at <a class="reference external" href="http://www.nelen-schuurmans.nl/">Nelen en Schuurmans</a> so I've started &quot;nensskel&quot; here :-)</p>
<p>Some examples of what I get when I create a new django site with
nensskel (after giving it a project name):</p>
<ul class="simple">
<li>Basic <tt class="docutils literal"><span class="pre">setup.py</span></tt> with project name filled in.  Long description is read
from the readme and changelog.  Some common dependencies are pre-filled.</li>
<li><tt class="docutils literal"><span class="pre">buildout.cfg</span></tt> which sets up django, creates apache config files, contains
package-versioning best practice setup, contains some commonly used tools,
etc.</li>
<li>Readme, changelog, todo file.  Of course with the project name in there.</li>
<li>Basic apache config file.  In here there's also the configuration that's
needed for django's static files.  And some caching setup.  And the wsgi
configuration.  And the setup needed for django-compressor.</li>
<li>A directory with the actual django app (empty <tt class="docutils literal"><span class="pre">models.py</span></tt>, <tt class="docutils literal"><span class="pre">views.py</span></tt>
and so).  A bit like how django's <tt class="docutils literal"><span class="pre">manage.py</span> <span class="pre">startapp</span></tt> does it, but now
with our own defaults.</li>
<li>Our own defaults?  Yes, for instance the boilerplate needed in
<tt class="docutils literal"><span class="pre">settings.py</span></tt> for our <a class="reference external" href="http://reinout.vanrees.org/weblog/2010/05/19/django-css-javascript-files.html">django-staticfiles css/js setup</a>.
You definitively don't want to type that by hand.</li>
<li>Pre-created <tt class="docutils literal"><span class="pre">PROJECTNAME/templates/PROJECTNAME</span></tt>,
<tt class="docutils literal"><span class="pre">PROJECTNAME/media/PROJECTNAME</span></tt> and <tt class="docutils literal"><span class="pre">PROJECTNAME/fixtures/</span></tt> directories.</li>
<li>Ready-made test setup just the way we like it.</li>
</ul>
<p>So: <strong>make it easy to do the right thing</strong>.  Let laziness work in your
favour.  Start a skeleton today!</p>
</div>

        </div>
      </content>

    </entry>
    
  <entry>
    <title>Dutch Django meeting in Amsterdam</title>
    <link rel="alternate" type="text/html"
          href="http://reinout.vanrees.org/weblog/2010/06/10/django-amsterdam.html" />
      <id>http://reinout.vanrees.org/weblog//weblog/2010/06/10/django-amsterdam.html</id>
      <author>
        <name>Reinout van Rees</name>
      </author>
      <published>2010-06-10T00:00:00+01:00</published>
      <updated>2010-06-10T09:20:00+01:00</updated>

      
      <category term="django" />
      
      <category term="pun" />
      
      <category term="plone" />
      
      <category term="buildout" />
      

      <content type="xhtml"
               xml:base="http://reinout.vanrees.org/weblog/"
               xml:lang="en-US"
               xml:space="preserve">
        <div xmlns="http://www.w3.org/1999/xhtml">
          <div class="document">
<div class="section" id="djangocon-eu-2011-news">
<h1>Djangocon.eu 2011 news</h1>
<p>Djangocon.eu 2011 is going to be organized in... <strong>Amsterdam</strong>!</p>
</div>
<div class="section" id="my-djangocon-eu-summary">
<h1>My djangocon.eu summary</h1>
<p>I opened the evening with a summary of last month's djangocon.eu conference.
I won't write down a summary of the summaries that I already made of all the
talks :-)  Some main points:</p>
<ul class="simple">
<li>Go to such a conference!  Good experience.  What to do?  How to get there?
What happens?</li>
<li>Django's own development.  The django technical panel, Jacob's keynote, the
bad pony talk, etc.</li>
<li>NoSQL.  A big hit at the conference with 3 talks and 1 panel.</li>
</ul>
<p>Some links I gave:</p>
<ul class="simple">
<li><a class="reference external" href="http://reinout.vanrees.org/weblog/tags/djangocon.html">My summaries</a>.</li>
<li>The <a class="reference external" href="http://djangoconeu.blip.tv/">videos of all the talks</a>.</li>
<li>Idan Gazit's <a class="reference external" href="http://reinout.vanrees.org/weblog/2010/05/26/design-for-developers.html">design for developers talk</a>.
Read it or, better, watch the video.  Highly recommended.</li>
</ul>
</div>
<div class="section" id="www-academictransfer-com-jan-murre">
<h1>www.academictransfer.com (Jan Murre)</h1>
<p>Subtitle: &quot;an academic Jobboard with Django. Also featuring: Plone and SOLR&quot;.
<a class="reference external" href="http://www.academictransfer.com">Academictransfer</a> is a spin-off from the
VSNU, the combined Dutch universities.  Academic transfer has a lot of
academic jobs in the Netherlands and they're expanding abroad.  It is really
focused on academic jobs.</p>
<p>Pareto, his company, uses Plone a lot.  Plone is a really good content
management system, but people sometimes abuse it for tasks for which it is not
suited.  Since a few years, they use Django for those kind of non-Plone-suited
projects.</p>
<p>The old side was a 10-year old coldfusion site.  A classic case of vendor
lock-in of the company that build them the original site.  Performance
problems and big problems at every change request.</p>
<p>They originally asked Pareto for a Plone website (&quot;it is a lot of content&quot;).
Plone is a good CMS, but this is mostly a database-driven site, so they
advised Django.</p>
<p>They also use SOLR.  SOLR is a high-end open source search engine (from the
apache world).  Till now, this has proven to be a good choice.</p>
<p>They use <a class="reference external" href="http://buildout.org">buildout</a> (<em>YEAH!</em> See my <a class="reference external" href="http://reinout.vanrees.org/weblog/tags/buildout.html">buildout articles</a>).  It is their
workhorse for setting up Django websites.  With a buildout config, you can
have a fresh, running django website within a minute.  (Note: read <a class="reference external" href="http://jacobian.org/writing/django-apps-with-buildout/">Jacob
Kaplan-Moss's article about Django and buildout</a>).</p>
<p>People are looking for a job, so the search functionality is the most
important part of the site.  SOLR works great.  It is good at searching with
<em>facets</em>.  A facet can be an organisation or a keyword or an academic field
for instance.</p>
<p>There's login and personalization.  Storing your queries; getting mails with
new vacancies.  Universities also can have their own page in the site.  Most
of the website is made with Django, but Plone is also used.  An apache config
divides up the requests between the both of them.</p>
<p>The UI is reused between Django and Plone.  They did this by having Django ask
plone for a base template.  What plone returns is a plone browser view, but it
is a <em>Django</em> template with Django's tags!  The base template is downloaded
with a cron job every night as the Plone site doesn't change that much.
Another option would have been <a class="reference external" href="http://deliveranceproject.org/">deliverance</a>.  Nice system.</p>
<p>A localization problem: Plone and Django use different methods for setting the
language.  Django stores it in the session and Plone uses a separate i18n
cookie.  The solution was to do the language switching on the Django side and
get Django to set the Plone cookie, too.  (An alternative could have been some
django i18n middleware).</p>
<p>User management is Django-only.  In the Plone pages, you want to show the
username, too, though.  The solution was to add an ajax call to the Plone
interface that asks Django for the username :-)</p>
<p>The whole website is cached with varnish (which is basically the standard in
the Plone world).  For the username stuff, they had to use aggressive cache
invalidation.  An alternative they're going to pursue is SSI (server side
includes).  A main reason is that such ajax injection goes against the
<em>webrichtlijnen</em> (Dutch accessibility guidelines).</p>
<p>They want to show some Django content, like recent job entries, in the Plone
homepage.  The solution: load those entries via RSS/Atom feeds in Plone
portlets.  You have to make those feeds anyway.</p>
<p>Website statistics are of course important.  The counters are stored in a
Redis store.  Redis is a very simple noSQL database that's basically only a
key/value store.  Lightning fast.  It uses http for connections.  He had some
doubts about that, but it turns out to be fast, too.  Google analytics wasn't
an option as academic transfer had some custom requirements.  Especially very
custom &quot;funnels&quot;.  Funnels are specific sequential steps that a customer can
take through the site.</p>
<p>Some extra features:</p>
<ul class="simple">
<li>Pluggable publication model so that you can submit to/from several
university's job sites.</li>
<li>Chinglish plugin: automatic English-Chinese translation.  The quality isn't
perfect, but it suffices to get translated job vacancies into China's main
&quot;baidu&quot; search engine.  The people that find it then can switch to English
for the &quot;real&quot; job vacancy.</li>
<li>Several import/exports.</li>
</ul>
<p>Question: when would you use Django, when Plone?  Answer: for <em>this</em> site,
they'd have gone with all-Django.  Plone is only used for only 15 pages.  But
if your site needs real CMS functionality, use Plone.  So if you need
workflows, per-page and per-folder security, stuff like that.  Don't build
anything like that yourself: it is already there in Plone.</p>
</div>
<div class="section" id="lightning-talks">
<h1>Lightning talks</h1>
<div class="section" id="updating-your-django-site-the-easy-way-dave-de-fijter">
<h2>Updating your django site, the easy way (Dave de Fijter)</h2>
<p>When you update your site, there are a lot of manual steps you need to do.
That's not DRY (don't repeat yourself).  Some options:</p>
<ul class="simple">
<li>Shell scripts (but you still need ssh).</li>
<li>Fabrik (pretty good, but not that friendly)</li>
<li>He proposes <a class="reference external" href="http://pypi.python.org/pypi/django-siteupdate">django-siteupdate</a>.  You can update your
sites from the django admin.  It keeps logs of your updates.  Custom update
scripts are possible, as is postprocessing.  You see the output of your
scripts in the django admin interface.</li>
</ul>
<p>(I mentioned a djangocon talk about capistrano.)</p>
</div>
<div class="section" id="dynamic-models-in-django-joeri-bekker">
<h2>Dynamic models in Django (Joeri Bekker)</h2>
<p>Dynamic models are not defined in your python code.  For instance, they're
created on the fly at runtime.  You could create a flexible admin this way.
Or you can dynamically prototype models without having python knowledge.</p>
<p>Or you can, before a syncdb, create dynamic copies of your old data models so
you can still access them.  Or, what he uses it for, generate <strong>additional
models for localization</strong>.</p>
<p>How?  Something like:</p>
<pre class="literal-block">
Person = type('Person', models.Model, attrs={..field...})
</pre>
<p>In the end, it is more involved of course.  Most of django's machinery still
works just fine with those classes.  You can run <em>syncdb</em> just fine from
within your code, creating the tables in your database.</p>
<p>So: do you have a usecase for this?  He said there was a nice article about
this subject on the Django website.</p>
</div>
<div class="section" id="my-app-engine-has-more-horsepower-than-your-pony-alper-cugun">
<h2>My App Engine has more horsepower than your Pony (Alper Cugun)</h2>
<p>Alper's been programming Django for 5 years.  Recently he's working with
google's app engine.</p>
<p>Django is good for content-heavy websites and for complex websites that are
composed of many apps.</p>
<p>App engine is made for scalability and availability.</p>
<p>The good things about app engine:</p>
<ul class="simple">
<li>The database (nosql!) is great.  SQL sucks.  NoSQL doesn't give you
migrations, so you don't have migration issues :-)</li>
<li>There's a python script that deploys to google in no time.  No
configuration, only programming.  It just works.</li>
<li>App engine comes with batteries included.  Memcache and all sorts of other
tools.  Handy.</li>
<li>Google makes sure it is scalable and always available and safe.</li>
</ul>
<p>The bad things:</p>
<ul class="simple">
<li>No serious queries.  No normalization.  Partially bad, but it enables some
of the good things.</li>
<li>There's a 30 second deadline for everything.  Something that takes to long
doesn't ever complete.</li>
<li>They are a bit focused on enterprisey stuff.</li>
</ul>
<p>Some tips: use indexes, memcache and create json endpoints.</p>
<p>It is ideal for getting stuff up and running quickly.  Instant gratification.
He wouldn't really tie his whole company to google at the moment.</p>
</div>
<div class="section" id="just-a-millisecond-achieving-performance-without-ramping-up-the-hardware-rick-van-hattem-thierry-schellenbach">
<h2>Just a millisecond, achieving performance without ramping up the hardware (Rick van Hattem &amp; Thierry Schellenbach)</h2>
<p>They got way too much traffic to one of their sites
(<a class="reference external" href="http://www.fashiolista.com/">http://www.fashiolista.com/</a>) as it got waaaay to popular.</p>
<p>A default approach is to cache pages in Django: the <tt class="docutils literal"><span class="pre">&#64;cache_page</span></tt>
decorator.</p>
<p>NGINX and memcached are also a great combination.</p>
<p>Their problem: most of the content is user-specific and thus uncacheable.</p>
<p>The solution: combination of SSI (server side includes) and javascript.
Memcached stores an anonymous page and the javascript knows how to turn it
into a personalized page.  SSI mixes in a bit of data with personalization
instructions into the page.  Javascript then applies those instructions.
This SSI mixed-in data is just a very small Django request.</p>
<p>He showed result statistics that were pretty sweet.</p>
<p>A bigger tutorial and code will be up soon at <a class="reference external" href="http://mellowmorning.com">http://mellowmorning.com</a></p>
</div>
<div class="section" id="class-based-views-roald-de-vries">
<h2>Class based views (Roald de Vries)</h2>
<p>His goal was to find an object oriented way to create reusable views for his
project.  Django had almost the same goal for its &quot;generic views&quot;.</p>
<p>He used the <tt class="docutils literal"><span class="pre">__init__()</span></tt> method and django is starting to use the
<tt class="docutils literal"><span class="pre">__call__()</span></tt> method.  The <tt class="docutils literal"><span class="pre">__call__()</span></tt> calls the actual methods that you
can override in subclasses.  The url pattern is a problem.  Thread-safety is
an issue, they're still thinking about an optimal solution.</p>
<p>An advantage of his <tt class="docutils literal"><span class="pre">__init__</span></tt> method is that the url pattern can stay the
same.  There are some disadvantages with subclassing and returning <tt class="docutils literal"><span class="pre">self</span></tt>.</p>
<p>Search the django developer mailing list for &quot;class based generic views in
1.3&quot; to get the full discussion.</p>
</div>
</div>
</div>

        </div>
      </content>

    </entry>
    
  <entry>
    <title>Benoît Chesneau: Relax your project with CouchDB</title>
    <link rel="alternate" type="text/html"
          href="http://reinout.vanrees.org/weblog/2010/05/26/couchdb.html" />
      <id>http://reinout.vanrees.org/weblog//weblog/2010/05/26/couchdb.html</id>
      <author>
        <name>Reinout van Rees</name>
      </author>
      <published>2010-05-26T00:00:00+01:00</published>
      <updated>2010-05-26T07:47:00+01:00</updated>

      
      <category term="django" />
      
      <category term="djangocon" />
      

      <content type="xhtml"
               xml:base="http://reinout.vanrees.org/weblog/"
               xml:lang="en-US"
               xml:space="preserve">
        <div xmlns="http://www.w3.org/1999/xhtml">
          <div class="document">
<p>Benoît is one of the CouchDB developers and the maintainer of CouchDBkit and a
couple of other packages.</p>
<p>Why go with a NoSQL database?  Often our data isn't 300GB and the data fits
one machine.  Scalability isn't always needed.  And regular SQL databases are
often fast enough, right?  Some reasons for NoSQL:</p>
<ul class="simple">
<li>Different kinds of data.  Often in Django you have lots of models.</li>
<li>Easy denormalisation.  You no longer have to make your data match the
relational normalisation theory.</li>
<li>Easy data migration.</li>
<li>Your data is safe.  With enough budget and machines, you can keep your sql
data safe.  Apparently it is easier and cheaper with a NoSQL database.</li>
<li>Flexibility and simplicity.</li>
</ul>
<p>Some CouchDB characteristics: map/reduce; REST interface; document oriented
database; append-only; replication.</p>
<p>Document oriented, what's that?  It means schema-less json with attachments.
So you can put any json you want into it, you don't have to define a schema
beforehand.  There's a web frontend called Futon to introspect your data
(basically phpmyadmin for CouchDB).</p>
<p>There's more. For instance sharding.  And <strong>geocouch</strong>, full r-tree.</p>
<p>CouchDBkit is a CouchDB python framework.  It is a simple client and it also
comes with a django extension.  The django extension allows you to define
models (if you want) so that you also can generate forms for it.</p>
<p>For the next version, he wants admin integration, some new mappings (objects
with annotations), eventlet support, multidb support.</p>
<p>Question: the current couchdb version is 0.11 or so.  Should we wait for 1.0?
Answer: just use the 0.11, it is stable.</p>
</div>

        </div>
      </content>

    </entry>
    

</feed>
