Posted in September 2008

Set permission_required for your view functions

Working with django 1.0 and google app engine… Wanted to set every view on my admin page to have admin permission.

def _perm_admin(rootfunc)  :
    import sys
    module = sys.modules.get(rootfunc.__module__)
    for key, value in module.__dict__.items() :
        if type(value) is types.FunctionType and key[0] != '_' and rootfunc.__module__ == value.__module__:
            module.__dict__[key] = permission_required('admin')(value)

_perm_admin(main)
Tagged ,

Python Documentation — Fail!

One of many rants against python documentation.  Fundamentally, things like this only re-enforce why it didn’t receive the rapid acceptance of PHP.

$ pydoc list

....
 |  index(...)
 |      L.index(value, [start, [stop]]) -> integer -- return first index of value
....

Ok, that’s good… But what about the “not found” case, is it documented, nope!  We have three choices, can you pick the right one?

  • Return None
  • Return -1
  • Throw an exception

So, what the documentation requires you to do is write three lines of code to understand how list.index() works.  This is fundamental failure of the maintainers of the language.

Tagged

Honor Role … or Killer …

I was driving down the road the other day and saw this bumper sticker on a car…  We’ve all see “Proud Parent of a XYZ School Honor Role” bumper stickers.  This was the first time that I saw a bumper sticker that somebody was proud that their child was a professional killer.

Proud Parent of a Sniper

While fundamentally I understand there is a need, is this the right message to be sending to the world?  Should we rant against Hollywood for glorification of killing, we’ll leave Grant Theft Auto out of the picture?