11 December 2008
Andrew and I spent a few days this week putting together a new Django project.
It’s called Layoff Talent and it’s a place for people in the tech industry who have been laid off and are looking for a new job. They can add a simple profile and then hopefully be picked up by employers looking for new talent.
It’s similar in some ways to Django People or the Djangogigs developer listings, but specifically for people who have been laid off and not restricted to Django developers.
There’s nothing ground breaking from a development point of view, but it’s another example of how Django makes it easy to put out a full-featured site in a short time. Of course, we’ll be adding more features as the site gets popular.
If you know someone who has been laid off, please tell them about layofftalent.com.
4 December 2008
Error emails contain session key
When you get an error email from your Django app telling you someone got a server error, it’s not always easy to tell which user had a problem. It might help your debugging to know or you might want to contact the user to tell them you have fixed the problem.
Assuming the user is logged in when they get the error, the email will contain the session key for that user’s session. The relevant part of the email looks like:
<WSGIRequest
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{ 'sessionid': '8cae76c505f15432b48c8292a7dd0e54'},
...
Finding the user from the session
If the session still exists we can find it, unpickle the data it contains and get the user id. Here’s a short script to do just that:
from django.contrib.sessions.models import Session
from django.contrib.auth.models import User
session_key = '8cae76c505f15432b48c8292a7dd0e54'
session = Session.objects.get(session_key=session_key)
uid = session.get_decoded().get('_auth_user_id')
user = User.objects.get(pk=uid)
print user.username, user.get_full_name(), user.email
There it is. Pass in the session key (sessionid cookie) and get back the user’s name and email address.
Plug: Get your own job board at Fuselagejobs