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.

1def _perm_admin(rootfunc)  :
2    import sys
3    module = sys.modules.get(rootfunc.__module__)
4    for key, value in module.__dict__.items() :
5        if type(value) is types.FunctionType and key[0] != '_' and rootfunc.__module__ == value.__module__:
6            module.__dict__[key] = permission_required('admin')(value)
7
8_perm_admin(main)