• Virtualenv med Python2.7 på FS-Data

    (This blogpost is just available in swedish, since it involves a swedish webhost)

    Jag har tidigare skrivit hur man får igång Django på FS-Data. För ett par månader sen så uppdaterade de sin Pythontolk till 2.7, vilket gjorde livet bra mycket roligare. Något som gör livet än mer roligare är virtualenv. Virtualenv är en virtuell miljö som du installerar dina pythonpaket i så slipper du paket som kolliderar eller, vara beroende av att paket installeras system wide. Portabiliteten blir superb genom att man bara specar ens pythonpaket i en fil (requirements.txt) som man sedan använder när man deployar ut sin kod. Virtualenv är de facto-standard i Pythonvärlden och något varje Pythonutvecklare borde lära sig.

    Här följer en kort guide för hur du får igång virtualenv på FS-Data.

    • SSH:a in på ditt FS-Datakonto, du kan göra livet lättare genom att logga in utan lösenord, vilket gör automatiska deployments bra mycket smidigare.

      ssh konto@konto.fsdata.se
    • Skapa en mapp där de pythonpaket du behöver installera på ditt konto ska bo.

      mkdir site-packages
    • Börja med att skapa .bash_profile och ändra i lite sökvägar:

      echo 'export PYTHONPATH=“$HOME/site-packages/"
      export PATH="$PATH:$HOME/site-packages/"' > .bash_profile
    • Installera pip och virtualenv genom easy_install

      easy_install --install-dir=$HOME/site-packages pip;
      easy_install --install-dir=$HOME/site-packages virtualenv
    • Nu har du allt som behövs för att skapa en virtualenv, hur du väljer att organisera dina virtualenv:er är upp till dig, men ett smidigt sätt är att använda virtualenvwrapper, men det är ett ämne för en kommande blogpost. Så, jag tar och hoppar in i www och skapar en mapp där.

      cd www;
      mkdir mappnamn;
      cd mappnamn
    • Nu är det bara att skapa din virtualenv, detta kommando skapar en virtualenv i mappen “env”

      virtualenv --no-site-packages --distribute env
    • Då var det bara att aktivera virtualenv:en

      source env/bin/activate

      Nu ska du se att din kommandorad har bytt stil och börja med “(env)”, detta är för att namnet på din virtualenv är just “env”, hade du i det föregående steget döpt den till “minwebshop” hade det stått just det.

    • Nu är det bara att installera paket i din virtualenv!

      pip install django;
      pip freeze

    Så, det var en liten snabbguide för hur man få igång virtualenv på FS-Datas delade miljö. Hittar du något fel så skriv gärna en kommentar nedan, fler guider i stil med denna kommer framöver.

  • Running two services at once on Dotcloud

    If you’re a regular of my old personal blog you know that I have tested most of the more well known Django hosting services.

    The reason I chose Dotcloud for this project was that it involved both Django and NodeJS, and to make it more of a mess it it as web that both is an online and an offline web (yep, HTML5 appcache). For the offline part we are actually using some CommonJS modules straight in the browser. And to protect these files and not get the application server to serve those files we needed to be able to customize the Nginx configuration. So to make all these pieces fit nicely on just one host the choice was pretty easy, Dotcloud.

    So how do we deploy a two (or more) service thingie in Dotcloud? It’s actually very easy. You just add one more service in your dotcloud.yml, like:

      type: python
      approot: cleverfoldername
      type: nodejs
      approot: cleverfoldername/node
        node_version: v0.6.x

    This will fire up two instances, one for the django service and one for the nodejs service. As you can see the root for the nodejs service is actually inside of the django service, this is because we are serving the commonjs modules for the offline web through the django servive, and since offline cache only works on the same domain this is a nice way to solve that.

    If you’re having any trouble please check your logs for that app, or ssh into the very service to dig deeper, if you’re having trouble with paths etc.

    So how is this Dotcloud working for this application? Just great, right now it’s in the sandbox flavor, which means it’s on a slower cluster, no custom domain and if not used for a while it will go into hibernate, which suits us just fine since it’s right now for testing and verification. One thing you should keep in mind, a service can’t be upgraded to a paid flavor, so that means you have to deploy it once more and move the database etc.

  • Apple, the new Volkswagen?

    When Apple presented the new version of Ios (6 that is) I was deeply disappointed, it was almost identical with the previous version but with some minor adjustments. It was using same kind of app centric homesecreen, and they had thrown in some notification drawer a la Android. When Apple presented Iphone 5 I was even more disappointed, the phone was exactly what had been leaked and nothing more. It was a tad thinner (guess so when you remove a big sheet of glass), a bit lighter, a bit longer. Not revolutionary but just evolutionary. And boring.

    After the Iphone event we had a discussion at work regarding this and someone mentioned that Apple has become the new Volkswagen. Both companies have with good products (Iphone and Golf) defined a nice segment of the market and are leaders in that segment. With that comes the fear to do anything drastic that potentially can alienate the customers. So the fear becomes the driving force instead of the eager to innovate. And that is the first sign of a company gone bad, or going bad.

    Some pictures for comparison

    Golf MK6 (previous generation) vs Gold MK7 (current generation)

    Sideview of all generations of Golf

  • Goodbye django

    It’s time to move on, on from Django to something else. I want to have a site that needs none or very little caretaking. Even if Gondor, Heroku et al make my work as a programmer much easier, but it’s not enough, I want things to be even easier. So I’m ditching Django and moving this blag to Pelican, a static site generator written in Python. Don’t worry, I will still use Django at work and for other projects, not just this one.

« Page 3 / 3