The function view_or_basicauth() has a bug. realm cannot be declared as a keyword before the variable *args. I believe the simple solution is to drop the assignment, otherwise you need to re-write to two callers ie: logged_in_or_basicauth and has_perm_or_basicauth. Removing the assignment seems like a safe action as both of the callers provide a default value.
Suggested signature:
def view_or_basicauth(view, request, test_func, realm, *args, **kwargs):