Project planning with google docs

January 30th, 2012

We use Google docs where I work, and I like to plot out developer task timelines. The easiest thing to do is set up the id, dependency, start, end, %done spreadsheet and use http://lifehacker.com/5070701/add-a-gantt-chart-to-your-google-spreadsheet to throw a gantt chart on the wall with the projector. Easy to do and review on the wall.

Android and HTML5 and HLS

November 5th, 2011

In the long running quest for HTML5 video on Android, now with HLS – I’ve yet to find a working example of HLS on Android 3.0+. Argh.

If you know of an example, please let me know.

NameVirtualHost and ServerName

October 4th, 2011

More of a note to myself – was having trouble with mod_wsgi and setting up different NameVirtualHost and ServerNames. Turned out the problem was I was including a .conf file that had multiple ServerName directives. Always check that first.

Django tip of the day – use pluralize

June 23rd, 2011

There are a bunch of built in template tags and filters to make things easier to read. Be sure to take a look at pluralize when building your pages.

It helps you easily use a plural suffix when you are listing counts of items.

Django user permissions allows is_superuser

March 29th, 2011

Small issue we found, if you want to give someone the ability to add/edit/delete users but don’t want them to be able to elevate privileges by setting is_superuser you have to monkey patch the UserAdmin class like this:

from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import ugettext_lazy as _

class MyUserAdmin(UserAdmin):
   my_fieldsets = (
       (None, {'fields': ('username', 'password')}),
      (_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),
       (_('Permissions'), {'fields':('is_active',)}),
    )

def change_view(self, request, object_id, extra_context=None):
     # for non-superuser
     if not request.user.is_superuser:
         self.fieldsets = self.my_fieldsets
         response = UserAdmin.change_view(self, request, object_id,
extra_context=None)
         return response
     else:
         return UserAdmin.change_view(self, request, object_id,
extra_context=None)

admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)

Then they won’t see the is_superuser checkbox. You’ll have to get a bit more fancy if you want to allow permission changes, but this is a good start.

Django AuthenticationForm is not showing errors but is_valid is False

March 3rd, 2011

Got bit by this one again, which I assume is going to be pretty common if you’re trying to use the AuthenticationForm as you would normally use a form.

When I use forms, I get into the habit of doing something like this:

if request.method == 'POST':
    f = MyForm(request.POST)
    if f.is_valid():
        do_whatever()

The problem when you use the AuthenticationForm is that __init__‘s has the first parameter named request. So if you do something like this:

if request.method == 'POST':
    f = AuthenticationForm(request.POST)
    if f.is_valid():
          do_whatever()

You’ll see that the form is not valid, but you won’t get any errors. The explanation is listed in the comments here: http://code.djangoproject.com/ticket/9803, but it’s painful to learn what went wrong.

The right way to use the AuthenticationForm is do this:

if request.method == 'POST':
     f = AuthenticationForm(data=request.POST)
     if f.is_valid():
         do_whatever()

How would I fix this?
Instead of doing this:

class AuthenticationForm(forms.Form):
     def __init__(self,request=None, *args, **kwargs):

I would make request be an optional named parameter, and check for it. That’s what the code is doing later on in the clean method anyway.

Pricing AppEngine

February 11th, 2011

Google has a survey asking prospective pricing for new AppEngine features, please take a few minutes and fill it out here: https://groups.google.com/d/topic/google-appengine/eBdE0hyVPhE/discussion

Using Django as an OAuth provider

February 10th, 2011

For a while I couldn’t understand why getting a request token wasn’t working from our Django server, it kept returning 401 – it is because mod_wsgi does not pass the Authorization header by default over to Django.

To get the Authorization header, add:

WSGIPassAuthorization On

to your configuration.

Code Rush

February 2nd, 2011

Code Rush is one of those movies that if you are in the startup world you will probably enjoy seeing. Also enjoyable are startup.com, tron, hackers, and wargames. If you get the chance, also read Brewing up a Business.

Hiring

January 27th, 2011

We’re in the process of adding members to our development team. If you are a software developer, I highly recommend putting your github url on your resume. It’s a huge plus if I can see something you’ve written. Schools should start adding this to the resume checklist they give to students.