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)