-
posts
-
Using Daemontools
Introduction daemontools is a set of programs for monitoring daemon programs and also restarts them immediately if they crash or are terminated. I generally use daemontools for daemons that are required and are always running websites. These include web servers, mail servers, monitoring servers and FastCGI servers. Processes Daemons usually run in the background so they don’t hold up the terminal. But daemontools works by keeping the standard pipe to the process open so that it can monitor when the process terminates. It knows when the process terminates because the pipe to the process is closed. This means that daemons...
-
Parsing email with attachments in python
Recently I needed to be able to parse out attachments and body from multipart emails and use the resulting data to post to a service. So I wrote the code below to parse out text and html portions of the email and also parse out attachments. The code below is the result. I used a StringIO object from the python StringIO module to hold attachment data because the PIL module seemed to not be able to recognize images unless I either used a python file object or a StringIO object. Since it relies on the python StringIO module rather than...
-
Annoying things about Django
Since I’ve been using it for a while now I’ve gotten a good idea about what is good and what is annoying about development with django. This might seem a little trite at parts since some of these gripes are with features that don’t exist in other frameworks but in the spirit of perhaps making django more flexable without ruining it’s ease of use I’ve come up with some annoying spots and possible ideas for fixing them. New Password Request Time Limit The new password request time limit can only be specified in days. This makes it impossible to use...
-
Custom Admin Views and Reversing Django Admin URLs
I recently used the new feature in Django 1.1 for reversing django admin URLs and specifying custom admin views in my project django-lifestream. django-lifestream has a custom admin view which allows users to update the lifestream manually. The code looks like the following: class ItemAdmin(admin.ModelAdmin): list_display = ('title', 'date','published') exclude = ['clean_content',] list_filter = ('feed',) search_fields = ('title','clean_content') list_per_page = 20 model = Item def save_model(self, request, obj, form, change): obj.clean_content = strip_tags(obj.content) obj.save() def admin_update_feeds(self, request): from lifestream.feeds import update_feeds #TODO: Add better error handling update_feeds() return HttpResponseRedirect( reverse("admin:lifestream_item_changelist") ) def get_urls(self): from django.conf.urls.defaults import * urls = super(ItemAdmin,...
-
Recent EC2 Problems
Over the weekend we had some problems with EC2 in which some instances could not be connected to via a network. This happened to us for a Nginx load balancing server on Friday and a database master on Saturday for two different web services. Several posts in the forums also indicated similar problems though rebooting the instance did not work for us. Bitbucket also went down on Saturday which I assume is related. I figured I would document what happened as Amazon didn’t release any information about it over the weekend and it wasn’t immediately clear what we should do...
-
Using Mercurial MQ
I recently started using mercurial’s mq extension at work as I found myself switching between changes a lot. I often had to set changes I was currently working on aside to do a merge or fix something that was more urgent. The mq extension makes that possible by managing patches and allowing you to put away changes into the patch queue. mq is included in mercurial’s distribution by default but you need to enable it in your .hgrc [extensions] mq = Ok, so now I’ll run through the most used commands. hg qinit When you want to create a new...
-
Django and nginx settings
One problem I keep encountering with setting up fastcgi with Django is
that the default nginx fastcgi parameters cause django to load the top
url no matter what url you try to go to. This is because the default
nginx fastcgi parameters pass the SCRIPT_NAME parameter to the django
instance which Django interprets incorrectly. In order to fix this you
need to rename the SCRIPT_NAME parameter to PATH_INFO.
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
-
Smipple
Yesterday I released a pet project I had been working on called Smipple. Smipple is a service for saving, organizing, and sharing snippets of code. I originally decided to create it because I was a user of Snipplr but I was frustrated because it was slow and hard to use and the XML-RPC API was buggy. There didn’t seem to be much response from the author or changes to the website either. So from there I decided that I would create it as a challenge because I had wanted to create an actual website that people could use including implementation...
-
Relaxing weekend
Reiko and her dog Lala came over and we had a pretty relaxing weekend. On Saturday we went to Kita no maru park which is very close to the Emporer’s palace in Tokyo. I like Kita no Maru because it’s fairly open and generally doesn’t have a lot of people around. There were a number of people there making bubbles. They used two long plastic rods with string attached to the ends. The string connected the ends of the two rods formed a loop. When you hold the rods together the string hangs together but when you move the rods...
-
Google App Engine SDK 1.2.3
The Google App Engine SDK 1.2.3 was just released and contains some often asked for goodies such as Django 1.0 support and support for a task queue API. I haven’t found much information about the Django 1.0 version in App Engine but here are some links with some related information about the Task Queue API. Google App Engine Blog The task queue API documentation Looks relatively complete. Offline Processing on App Engine: a Look Ahead This is the session at Google I/O where Brett Slatkin talks about the task queue API. I attended the talk in person and it was...