It’s movie time: Plone 4 installation tutorial

This blog post starts long overdue series of Sauna Sprint 2011 results.

Sauna Sprint 2011 was held in Tampere, Finland and it was a shared venture of EESTEC student organization and Plone open source community. Due to circumstances on the venue we were not probably as productive, measured  in quantity, as one could have been when locked in to the university basement with one gigabit fiber connection. However, I believe the seeds of this sprint will hopefully have some long lasting positive effects to make Plone more admin and developer friendly.

During the first sprint day the EESTEC students got a head first dive to learn Linux and Plone. Based on their expressions they didn’t have 100% fun time when trying to get Plone running on their computer…. or after getting it there doing basic admin things like installing add-ons and keep Plone still going on. Especially on the Windows platform which actually receives most downloads (as mentioned by in random IRC conversation by one Plonista) installing Plone + add-ons was not entirely trouble-free. It is unforgivable that an attempt to install an add-on will ruin your site to non-working state. Of course you can fix buildouts and things, but how to do it is unreachable for the audience piloting Plone and thus such information effectively does not exist. The default support answer “recover for back-ups” is not fun either.

The fellowship of sprint could not fix Plone site admin and developer experience altogether as someone had to warm up sauna and others were hunting mooses for the food. However a brave team of EESTEC students recorded a basic installation tutorial video for Plone 4 for Linux. Now I finally have been able to upload this to YouTube and it’s time for the global premier of the movie:

Yarr…. Kudos for the tutorial video team! Everything that counts in as making it easier for people to enter Plone is what the community needs. Hopefully this will inspire thought for the upcoming Plone conference and sprints.

Ps. Happy talk like a pirate day ⚓

\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+

HTTP Referer based redirects in Apache

Referer HTTP header is a HTTP request field tellling the page the browser was on prior clicking link on it. It answers the question “where the user is coming from to my site”. Also the browsers use it for telling on which page images and other media was referred or embedded in.  The most common use case using HTTP Referer redicts is prevent image hot linking, but I had a use case where I’d like to migrate some traffic to a new domain, based on where the traffic is coming from. A referer based redirect is a solution for this.

HTTP Referer header is HTTP_REFERER environment variable in Apache mod_rewrite procesing context.

Here is a sample snippet which you can toss into virtualhost conf or .htaccess. It matches domain name in any part of HTTP referer (path part too) so it is not water-proof, but for 99,99% cases it works. If the user is coming to some of the mentioned domains the user will be redirected to the new site.

RewriteEngine On
RewriteCond %{HTTP_REFERER} .*plone.org.*$ [OR]
RewriteCond %{HTTP_REFERER} .*ubuntuforums.org.*$ [OR]
RewriteCond %{HTTP_REFERER} .*stackoverflow.com.*$ [OR]
RewriteCond %{HTTP_REFERER} .*sourceforge.net.*$ [OR]
RewriteCond %{HTTP_REFERER} .*ubuntu.ru.*$ [OR]
RewriteCond %{HTTP_REFERER} .*python.org.*$ [OR]
RewriteCond %{HTTP_REFERER} .*kotelett.no.*$
RewriteRule ^(.*)$ http://opensourcehacker.com/

More info

(I hate it when Apache cannot suggest links to the current version of documentation)

\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+

Fix Linux filename encodings with Python

We recently deployed a web based system to old Red Hat installation still using latin-1 as primary encoding for its filesystem. This caused headscratching as we were using Ubuntu during the development which uses UTF-8 encoding for filenames. Files were copied to the production server using rsync. When ls command was used in a terminal everything seemed be fine, because terminal itself was configured to UTF-8 and thus decoded the filenames when outputted to the terminal. However the web server was unable to serve images containing Finnish ä and ö characters in filenames.

After the headscratching was over we had figured out that renaming filenames to use latin-1 encoding makes the web server serve them fine. If it were a fresh start I’d rather configure the server itself to use now prevailent UTF-8, but because the infrastructure was shared with other, older, projects this was out of the question.

Thus, the script below was created to address the filename encoding problem (syntax highlighting available on the orignal publication):

#!/usr/bin/python
"""

    Recursively fix filename encoding problems

    http://www.opensourcehacker.com, MIT licensed

"""

import os

# Source filename encoding
FROM="utf-8"

# Target filename encoding
TO="latin-1"

# Current working directory
PATH=os.getcwd()

for root, dirs, files in os.walk(PATH):

    # Assume files are 8-bit strings in the native encoding
    # of the system which we cannot know
    for f in files:
        try:
            decoded = f.decode(FROM)
        except UnicodeDecodeError:
            print "Cannot decode:" + f
            continue

        fullpath = os.path.join(root, f)

        newpath = os.path.join(root, decoded.encode(TO))

        if newpath != fullpath:
            print "Renaming:" + fullpath + " to:" + newpath
            os.rename(fullpath, newpath)

I still don’t know how to verify / check / guess which encoding Linux file systems are using (if not UTF-8…), so someone please enlight me. In this case we learnt this by a smart guess and testing: we created two filenames, one name encoded with UTF-8 and one encoded with Latin-1 and see which file the web server was giving for us. I am also unsure whether the fact that files were orignally kept in Subversion repository and committed there from Windows had anything to do with the problem.

\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+

3 reasons why you should send your corporate representative to PyCon (Finland)

PyCon is a network of conferences around the globe related to Python programming language and technologies. PyCon Finland is now arranged for the second time (two weeks to the registration deadline!) I am writing this blog post in hope to encourage and inspire companies and organizations to participate in this wonderful event and also see the business benefits of doing so. As a disclaimer I am one of the event organizers and thus this post is also a non-paid advertisement of the event.

1. For constant innovation choose Python

To stay competitive it’s not enough for you to do the same thing as yesterday. It’s a deceivingly comfortable choice: no one has been fired for doing the same choices as done on the year before. But we have learn something dearly in Finland: the comfortability of no change comes with a terrible price. You’ll soon follow the fate of 00s mobile operating system: when you keep clinging on the old way the competitors will soon show the better way.

Python has proven its reputation as an agile technology platform. How about doing a small or medium sized project with Python instead of using (too) heavy enterprise tools? Think about if you could get all the time saved back in your next annual bonus? Here is a good related essay “Beating the Averages” from Paul Graham.

PyCon is the best place to see and learn the latest secret weapons Python has to offer. Many of open souce hackers, who write the development tools, are present in person. For example, in PyCon Finland we have Andy Smith from Rackspace (cloooouds). Be at the event and pump all the knowledge out of the brains of the masterminds.

2. Be global, act local

Spotify will be present with a considerable delegation. For those who live in a barrel (no offense US) Spotify is (was?) a real hot Swedish start-up which seeks to dethrone iTunes in the game of global digital music consumption.

Besides Spotify from Sweden, we have plenty of other international guests. The window of new opportunities is open when organizations having similar competency background meet (read: Python). I have been personally participating in ventures which started as  chit-chat in a conference and later developed into full blown businesses just because people and companies with the same mindset where given a chance.

SMEs might have developed technologies for which they seek new channels of marketing. A trending website might need a new localization. You can find new clients for whom to subcontract your Python talent.. or anything in between. When you are dealing with international people already familiar with the core technology you have much more trust for being able to work together. There is no fear of conflict of interest as market area geographies are isolated (especially true in EU).

3. Best of the best

I have heard rumors that there is a shortage of Python programmers in Finland to hire. There exists a simple explanation: The Python programmers are the best programmers out there and thus they already have the best jobs.

PyCon Finland is the place to meet Python programmers as they have been nicely gathered into one place for you to pick. This is your once in a year chance to verify the fact whether all the best programmers are already hired. (note: if you manage to disprove me I am not offering beer prize or anything)

 

 

\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+