From 2c4666541591582220a127b50746cbd0284dec12 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 19 Jun 2015 14:02:51 -0400 Subject: [PATCH] Optimize the generate_headers check to skip the permissions load when we don't need it --- endpoints/index.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/endpoints/index.py b/endpoints/index.py index 96779cc06..2e690095f 100644 --- a/endpoints/index.py +++ b/endpoints/index.py @@ -55,10 +55,10 @@ def generate_headers(scope=GrantType.READ_REPOSITORY, add_grant_for_status=None) grants = [] if scope == GrantType.READ_REPOSITORY: - if ReadRepositoryPermission(namespace, repository).can() or force_grant: + if force_grant or ReadRepositoryPermission(namespace, repository).can(): grants.append(repository_read_grant(namespace, repository)) elif scope == GrantType.WRITE_REPOSITORY: - if ModifyRepositoryPermission(namespace, repository).can() or force_grant: + if force_grant or ModifyRepositoryPermission(namespace, repository).can(): grants.append(repository_write_grant(namespace, repository)) # Generate a signed token for the user (if any) and the grants (if any)