Twisted Python Twitter library with OAuth support

I have just pushed OAuth support in  my Twitty Twister branch on GitHub. This library created by dustin allows to access the Twitter API  using Twisted for Python: a high performance networking engine. It is to my knowledge the first Twitter library written in Python that supports authentication via OAuth. My version of Twitty Twister is backward compatible, allows to choose between standard or OAuth authentication and even allows to change the user’s avatar via OAuth.

The library does not currently support tokens exchanges (the login flow). So, to use this library and the associated examples you need to  register your application on Twitter and get users access tokens using something like Django Twitter Auth for Django.

The 4 first parameters of the examples commands (files ending with in the example/ directory) are always the application’s key, the application’s secret, the user’s key and the user’s secret. See the OAuth Twitter  FAQ for futher information.

Have fun!

Tweet13 sur Presse-Citron

Ok ça date un peu, comme vous avez pu le constater je n’ai pas eu l’occasion de bloguer beaucoup ces temps ci.

Mon dernier jouet pour Twitter, Tweet13, à fait l’objet d’une revue par Eric Dupin sur son blog Presse-Citron. Merci à lui !

Pour rappel Tweet13 est une petite application web qui permet de chiffrer les messages Twitter à l’aide de ROT13 avant des les envoyer.

En parlant d’applications Twitter, je vous en ai concocter une nouvelle sur le thème de la musique qui devrait être disponible sous peu 🙂

Joyeuses fêtes à tous.

Jouons un peu avec Tweet13

Voici Tweet13, le dernier petit gadget Twitter que je viens de programmer.

Comme son nom l’indique, Tweet13 chiffre vos updates Twitter avec ROT13 et ajoute optionellement un lien pour déchiffrer le message.

Quel intérêt de chiffrer un message si tout le monde peut le lire ?
Révéler la fin des films que vous avez vu, donner la réponse à de petits quizz que vous avez créés ou encore parler plus crument que d’habitude sans choquer vos followers sensibles 🙂

Tweet13 à été développé avec Django, JQuery et l’API Twitter.

Voir Tweet13.

Build your own website thumbnail generator with Django

On many website you can see a awesome link preview effect using a thumbnail of the page. There is some web services such as Websnapr or Thumbalizr providing an API to make your own webpages screenshots but it can be annoying to rely on third party projects: free accounts can only display a small among of screenshots and, cannot customize the size of the image, you cannot render Flash animations or Javascript…

Webkit Logo

We will build a website thumbnail generator using CutyCapt, a Webkit based free software designed to make screenshots of web pages, and Django, the powerful Python web framework.

The first step is to download and install CutyCapt. On a Debian-based system (such as Ubuntu) just type the following commands:

sudo apt-get install subversion libqt4-webkit libqt4-dev g++
svn co
cd cutycapt/CutyCapt
./CutyCapt --url=// --out=example.png

Try to open the example.png (i.e: eog example.png), if the install is OK you must see a screenshot of this blog.

I assume your Django installation is working fine. Start a new project if needed ( startproject mysite) and create an application called webthumb

with python startapp in your project.

Django Reinhardt

Edit your file to add a new pattern to the tuple urlpatterns. It will match screenshots requests and call the thumb view:

(r'^thumb/(?P.*)', 'mysite.webthumb.views.thumb'),

Now create a view called thumb in webthumb/ with this code:

import os
import subprocess
import md5
from django.http import HttpResponse

CUTYCAPT = '/home/dunglas/cutycapt/CutyCapt/CutyCapt'
THUMBS_DIR  = '/home/dunglas/Documents/Projets/kakofony/thumbs/'

def thumb(request, url):
    hash =
    path = THUMBS_DIR + hash + '.png'
    print path

    if not os.path.isfile(path):
                '--url=' + url,\
                '--out=' + path])
        except subprocess.CalledProcessError:
            return django.http.HttpResponseServerError

    img = open(path, 'rb').read()
    return django.http.HttpResponse(img, mimetype='image/png')

Adapt the variables CUTYCAPT and THUMBS_DIR with your settings. Of course the directory pointed by THUMBS_DIR must be writeable (chmod 777).

You can now embed website thumbnails in your websites just with this HTML markup <img src="http://localhost/thumb///" alt="Lapin Blanc" />.

Enjoy !

The last update of Aptana block Django development server

The last update of Aptana Studio come with a new built-in Jetty-based HTTP server running on port 8000… the same as Django development server. There is no good way to disable the preview server feature of the popular editor, but our favorite web framework can be launched on another port. Just type python runserver 8080 instead of python and access to your work on http://localhost:8080.

Django logo