{"action":"created","comment":{"url":"https://api.github.com/repos/shotgunsoftware/tk-core/pulls/comments/79164894","id":79164894,"diff_hunk":"@@ -255,31 +264,48 @@ def resolve_shotgun_configuration(\n             # resolve primary and user config\n             primary_config = None\n             user_config = None\n+            secondary_primary_config = None\n+            secondary_user_config = None\n+\n             for pc in pipeline_configs:\n \n                 # make sure configuration matches our entry point\n \n-                if self.__match_plugin_id(pc.get(\"plugin_ids\")) or self.__match_plugin_id(pc.get(\"sg_plugin_ids\")):\n+                if self._match_plugin_id(pc.get(\"plugin_ids\")) or self._match_plugin_id(pc.get(\"sg_plugin_ids\")):\n                     # we have a matching pipeline configuration!\n \n-                    if pc[\"code\"] == constants.PRIMARY_PIPELINE_CONFIG_NAME:\n-                        if primary_config:\n-                            log.warning(\n-                                \"More than one pipeline config detected. Will use the most \"\n-                                \"recently updated one.\"\n-                            )\n-                        primary_config = pc\n+                    if pc[\"project\"] == self._proj_entity_dict:\n+                        # this is a direct match\n+                        if pc[\"code\"] == constants.PRIMARY_PIPELINE_CONFIG_NAME:\n+                            log.debug(\"Primary match: %s\" % pc)\n+                            primary_config = pc\n+                        else:\n+                            user_config = pc\n+                            log.debug(\"Per-user match: %s\" % pc)\n+\n                     else:\n-                        # user config\n-                        if user_config:\n-                            log.warning(\n-                                \"More than one user config detected. Will use the most \"\n-                                \"recently updated one.\"\n-                            )\n-                        user_config = pc\n+                        # this is the site level fallback\n+                        if pc[\"code\"] == constants.PRIMARY_PIPELINE_CONFIG_NAME:\n+                            secondary_primary_config = pc\n+                            log.debug(\"Site level override match: %s\" % pc)\n+                        else:\n+                            secondary_user_config = pc\n+                            log.debug(\"Site level per-user match: %s\" % pc)\n+\n+\n+            # select in order of priority:\n+            # - a Primary config with project None (least prio)\n+            # - a Primary config matching the project\n+            # - a per user config with project None\n+            # - a per user config matching the project (most prio)\n+            pipeline_config = secondary_primary_config\n+            if primary_config:\n+                pipeline_config = primary_config\n+            if secondary_user_config:\n+                pipeline_config = secondary_user_config\n+            if user_config:\n+                pipeline_config = user_config","path":"python/tank/bootstrap/resolver.py","position":153,"original_position":153,"commit_id":"22657ee8f8d4a7aa30360b0b0d6c9e9221ff096f","original_commit_id":"22657ee8f8d4a7aa30360b0b0d6c9e9221ff096f","user":{"login":"josh-t","id":2604646,"avatar_url":"https://avatars.githubusercontent.com/u/2604646?v=3","gravatar_id":"","url":"https://api.github.com/users/josh-t","html_url":"https://github.com/josh-t","followers_url":"https://api.github.com/users/josh-t/followers","following_url":"https://api.github.com/users/josh-t/following{/other_user}","gists_url":"https://api.github.com/users/josh-t/gists{/gist_id}","starred_url":"https://api.github.com/users/josh-t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josh-t/subscriptions","organizations_url":"https://api.github.com/users/josh-t/orgs","repos_url":"https://api.github.com/users/josh-t/repos","events_url":"https://api.github.com/users/josh-t/events{/privacy}","received_events_url":"https://api.github.com/users/josh-t/received_events","type":"User","site_admin":false},"body":"This section is a little confusing. Wondering if it would help to interleave the comments into the conditionals? Also, should these be structured as `if/elif` statements?\r\n\r\n```python\r\n# select in order of priority:\r\nif project_user_config:\r\n    # - a per user config matching the project\r\n    pipeline_config = project_user_config\r\nelif project_primary_config:\r\n    # - a Primary config matching the project\r\n    pipeline_config = project_primary_config\r\nelif site_user_config:\r\n    # - a per user config with project None\r\n    pipeline_config = site_user_config\r\nelif site_primary_config:\r\n    # - a Primary config with project None\r\n    pipeline_config = site_primary_config\r\nelse:\r\n    # - No pipeline config found, fallback to the base config\r\n    pipeline_config = None\r\n```\r\n\r\nMaybe a little too explicit?","created_at":"2016-09-16T13:07:05Z","updated_at":"2016-09-16T13:08:45Z","html_url":"https://github.com/shotgunsoftware/tk-core/pull/337#discussion_r79164894","pull_request_url":"https://api.github.com/repos/shotgunsoftware/tk-core/pulls/337","_links":{"self":{"href":"https://api.github.com/repos/shotgunsoftware/tk-core/pulls/comments/79164894"},"html":{"href":"https://github.com/shotgunsoftware/tk-core/pull/337#discussion_r79164894"},"pull_request":{"href":"https://api.github.com/repos/shotgunsoftware/tk-core/pulls/337"}}},"pull_request":{"url":"https://api.github.com/repos/shotgunsoftware/tk-core/pulls/337","id":85545354,"html_url":"https://github.com/shotgunsoftware/tk-core/pull/337","diff_url":"https://github.com/shotgunsoftware/tk-core/pull/337.diff","patch_url":"https://github.com/shotgunsoftware/tk-core/pull/337.patch","issue_url":"https://api.github.com/repos/shotgunsoftware/tk-core/issues/337","number":337,"state":"open","locked":false,"title":"#38304 #37933 entry point > plugin id, site level overrides","user":{"login":"manneohrstrom","id":337710,"avatar_url":"https://avatars.githubusercontent.com/u/337710?v=3","gravatar_id":"","url":"https://api.github.com/users/manneohrstrom","html_url":"https://github.com/manneohrstrom","followers_url":"https://api.github.com/users/manneohrstrom/followers","following_url":"https://api.github.com/users/manneohrstrom/following{/other_user}","gists_url":"https://api.github.com/users/manneohrstrom/gists{/gist_id}","starred_url":"https://api.github.com/users/manneohrstrom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manneohrstrom/subscriptions","organizations_url":"https://api.github.com/users/manneohrstrom/orgs","repos_url":"https://api.github.com/users/manneohrstrom/repos","events_url":"https://api.github.com/users/manneohrstrom/events{/privacy}","received_events_url":"https://api.github.com/users/manneohrstrom/received_events","type":"User","site_admin":false},"body":"This renames `entry_point` to `plugin_id` across the code. Existing plugins are likely (but not guaranteed) to be backwards compatible.\r\n\r\nAlso implements site level overrides for pipeline configurations. Practically, this means that if you are user john smith and you start up the following:\r\n\r\n```\r\nmgr = sgtk.bootstrap.ToolkitManager()\r\nmgr.base_configuration = \"sgtk:descriptor:app_store?name=tk-config-default\"\r\nmgr.plugin_id = \"test.maya\"\r\nmgr.bootstrap_engine(\"tk-maya\", entity={\"type\": \"Project\", \"id\": 123})\r\n```\r\n\r\nThe following resolution order will be attempted:\r\n\r\n1. First toolkit will check for a project level, user associated pipeline configuration with\r\n   - `PipelineConfig.users` field containing john smith\r\n   - `PipelineConfig.project` field set to project 123\r\n   - `PipelineConfig.plugin_id` matching `test.maya`\r\n\r\n2. Next it will check for a project level primary config:\r\n   - `PipelineConfig.code` field set to `Primary`\r\n   - `PipelineConfig.project` field set to project 123\r\n   - `PipelineConfig.plugin_id` matching `test.maya`\r\n\r\n3. Next it will check for any user associated pipeline config with matching plugin id:\r\n   - `PipelineConfig.users` field containing john smith\r\n   - `PipelineConfig.plugin_id` matching `test.maya`\r\n\r\n4. Next it checks for a primary config matching plugin id:\r\n   - `PipelineConfig.code` field set to `Primary`\r\n   - `PipelineConfig.plugin_id` matching `test.maya`\r\n\r\n5. if none of the above returns a valid config, it falls back on the base config.\r\n\r\nThis means that you can set up both dev sandboxes and configs that will be used across *all projects* on your site. These can in turn be overridden per project if needed.","created_at":"2016-09-16T09:48:06Z","updated_at":"2016-09-16T13:08:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"db9a8dba0c4f89b3ab1194bf597e34eefd33968c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/shotgunsoftware/tk-core/pulls/337/commits","review_comments_url":"https://api.github.com/repos/shotgunsoftware/tk-core/pulls/337/comments","review_comment_url":"https://api.github.com/repos/shotgunsoftware/tk-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/shotgunsoftware/tk-core/issues/337/comments","statuses_url":"https://api.github.com/repos/shotgunsoftware/tk-core/statuses/22657ee8f8d4a7aa30360b0b0d6c9e9221ff096f","head":{"label":"shotgunsoftware:37933_plugin_id","ref":"37933_plugin_id","sha":"22657ee8f8d4a7aa30360b0b0d6c9e9221ff096f","user":{"login":"shotgunsoftware","id":317894,"avatar_url":"https://avatars.githubusercontent.com/u/317894?v=3","gravatar_id":"","url":"https://api.github.com/users/shotgunsoftware","html_url":"https://github.com/shotgunsoftware","followers_url":"https://api.github.com/users/shotgunsoftware/followers","following_url":"https://api.github.com/users/shotgunsoftware/following{/other_user}","gists_url":"https://api.github.com/users/shotgunsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/shotgunsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shotgunsoftware/subscriptions","organizations_url":"https://api.github.com/users/shotgunsoftware/orgs","repos_url":"https://api.github.com/users/shotgunsoftware/repos","events_url":"https://api.github.com/users/shotgunsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/shotgunsoftware/received_events","type":"Organization","site_admin":false},"repo":{"id":4270061,"name":"tk-core","full_name":"shotgunsoftware/tk-core","owner":{"login":"shotgunsoftware","id":317894,"avatar_url":"https://avatars.githubusercontent.com/u/317894?v=3","gravatar_id":"","url":"https://api.github.com/users/shotgunsoftware","html_url":"https://github.com/shotgunsoftware","followers_url":"https://api.github.com/users/shotgunsoftware/followers","following_url":"https://api.github.com/users/shotgunsoftware/following{/other_user}","gists_url":"https://api.github.com/users/shotgunsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/shotgunsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shotgunsoftware/subscriptions","organizations_url":"https://api.github.com/users/shotgunsoftware/orgs","repos_url":"https://api.github.com/users/shotgunsoftware/repos","events_url":"https://api.github.com/users/shotgunsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/shotgunsoftware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shotgunsoftware/tk-core","description":"The Shotgun Pipeline Toolkit Core API","fork":false,"url":"https://api.github.com/repos/shotgunsoftware/tk-core","forks_url":"https://api.github.com/repos/shotgunsoftware/tk-core/forks","keys_url":"https://api.github.com/repos/shotgunsoftware/tk-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shotgunsoftware/tk-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shotgunsoftware/tk-core/teams","hooks_url":"https://api.github.com/repos/shotgunsoftware/tk-core/hooks","issue_events_url":"https://api.github.com/repos/shotgunsoftware/tk-core/issues/events{/number}","events_url":"https://api.github.com/repos/shotgunsoftware/tk-core/events","assignees_url":"https://api.github.com/repos/shotgunsoftware/tk-core/assignees{/user}","branches_url":"https://api.github.com/repos/shotgunsoftware/tk-core/branches{/branch}","tags_url":"https://api.github.com/repos/shotgunsoftware/tk-core/tags","blobs_url":"https://api.github.com/repos/shotgunsoftware/tk-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shotgunsoftware/tk-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shotgunsoftware/tk-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/shotgunsoftware/tk-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shotgunsoftware/tk-core/statuses/{sha}","languages_url":"https://api.github.com/repos/shotgunsoftware/tk-core/languages","stargazers_url":"https://api.github.com/repos/shotgunsoftware/tk-core/stargazers","contributors_url":"https://api.github.com/repos/shotgunsoftware/tk-core/contributors","subscribers_url":"https://api.github.com/repos/shotgunsoftware/tk-core/subscribers","subscription_url":"https://api.github.com/repos/shotgunsoftware/tk-core/subscription","commits_url":"https://api.github.com/repos/shotgunsoftware/tk-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/shotgunsoftware/tk-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/shotgunsoftware/tk-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/shotgunsoftware/tk-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/shotgunsoftware/tk-core/contents/{+path}","compare_url":"https://api.github.com/repos/shotgunsoftware/tk-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shotgunsoftware/tk-core/merges","archive_url":"https://api.github.com/repos/shotgunsoftware/tk-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shotgunsoftware/tk-core/downloads","issues_url":"https://api.github.com/repos/shotgunsoftware/tk-core/issues{/number}","pulls_url":"https://api.github.com/repos/shotgunsoftware/tk-core/pulls{/number}","milestones_url":"https://api.github.com/repos/shotgunsoftware/tk-core/milestones{/number}","notifications_url":"https://api.github.com/repos/shotgunsoftware/tk-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shotgunsoftware/tk-core/labels{/name}","releases_url":"https://api.github.com/repos/shotgunsoftware/tk-core/releases{/id}","deployments_url":"https://api.github.com/repos/shotgunsoftware/tk-core/deployments","created_at":"2012-05-09T09:12:06Z","updated_at":"2016-09-08T07:11:16Z","pushed_at":"2016-09-16T11:57:20Z","git_url":"git://github.com/shotgunsoftware/tk-core.git","ssh_url":"git@github.com:shotgunsoftware/tk-core.git","clone_url":"https://github.com/shotgunsoftware/tk-core.git","svn_url":"https://github.com/shotgunsoftware/tk-core","homepage":"","size":39855,"stargazers_count":27,"watchers_count":27,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":23,"mirror_url":null,"open_issues_count":17,"forks":23,"open_issues":17,"watchers":27,"default_branch":"master"}},"base":{"label":"shotgunsoftware:master","ref":"master","sha":"806a74ab3db594b0db54be8c6c01dc97983341e4","user":{"login":"shotgunsoftware","id":317894,"avatar_url":"https://avatars.githubusercontent.com/u/317894?v=3","gravatar_id":"","url":"https://api.github.com/users/shotgunsoftware","html_url":"https://github.com/shotgunsoftware","followers_url":"https://api.github.com/users/shotgunsoftware/followers","following_url":"https://api.github.com/users/shotgunsoftware/following{/other_user}","gists_url":"https://api.github.com/users/shotgunsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/shotgunsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shotgunsoftware/subscriptions","organizations_url":"https://api.github.com/users/shotgunsoftware/orgs","repos_url":"https://api.github.com/users/shotgunsoftware/repos","events_url":"https://api.github.com/users/shotgunsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/shotgunsoftware/received_events","type":"Organization","site_admin":false},"repo":{"id":4270061,"name":"tk-core","full_name":"shotgunsoftware/tk-core","owner":{"login":"shotgunsoftware","id":317894,"avatar_url":"https://avatars.githubusercontent.com/u/317894?v=3","gravatar_id":"","url":"https://api.github.com/users/shotgunsoftware","html_url":"https://github.com/shotgunsoftware","followers_url":"https://api.github.com/users/shotgunsoftware/followers","following_url":"https://api.github.com/users/shotgunsoftware/following{/other_user}","gists_url":"https://api.github.com/users/shotgunsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/shotgunsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shotgunsoftware/subscriptions","organizations_url":"https://api.github.com/users/shotgunsoftware/orgs","repos_url":"https://api.github.com/users/shotgunsoftware/repos","events_url":"https://api.github.com/users/shotgunsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/shotgunsoftware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shotgunsoftware/tk-core","description":"The Shotgun Pipeline Toolkit Core API","fork":false,"url":"https://api.github.com/repos/shotgunsoftware/tk-core","forks_url":"https://api.github.com/repos/shotgunsoftware/tk-core/forks","keys_url":"https://api.github.com/repos/shotgunsoftware/tk-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shotgunsoftware/tk-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shotgunsoftware/tk-core/teams","hooks_url":"https://api.github.com/repos/shotgunsoftware/tk-core/hooks","issue_events_url":"https://api.github.com/repos/shotgunsoftware/tk-core/issues/events{/number}","events_url":"https://api.github.com/repos/shotgunsoftware/tk-core/events","assignees_url":"https://api.github.com/repos/shotgunsoftware/tk-core/assignees{/user}","branches_url":"https://api.github.com/repos/shotgunsoftware/tk-core/branches{/branch}","tags_url":"https://api.github.com/repos/shotgunsoftware/tk-core/tags","blobs_url":"https://api.github.com/repos/shotgunsoftware/tk-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shotgunsoftware/tk-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shotgunsoftware/tk-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/shotgunsoftware/tk-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shotgunsoftware/tk-core/statuses/{sha}","languages_url":"https://api.github.com/repos/shotgunsoftware/tk-core/languages","stargazers_url":"https://api.github.com/repos/shotgunsoftware/tk-core/stargazers","contributors_url":"https://api.github.com/repos/shotgunsoftware/tk-core/contributors","subscribers_url":"https://api.github.com/repos/shotgunsoftware/tk-core/subscribers","subscription_url":"https://api.github.com/repos/shotgunsoftware/tk-core/subscription","commits_url":"https://api.github.com/repos/shotgunsoftware/tk-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/shotgunsoftware/tk-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/shotgunsoftware/tk-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/shotgunsoftware/tk-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/shotgunsoftware/tk-core/contents/{+path}","compare_url":"https://api.github.com/repos/shotgunsoftware/tk-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shotgunsoftware/tk-core/merges","archive_url":"https://api.github.com/repos/shotgunsoftware/tk-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shotgunsoftware/tk-core/downloads","issues_url":"https://api.github.com/repos/shotgunsoftware/tk-core/issues{/number}","pulls_url":"https://api.github.com/repos/shotgunsoftware/tk-core/pulls{/number}","milestones_url":"https://api.github.com/repos/shotgunsoftware/tk-core/milestones{/number}","notifications_url":"https://api.github.com/repos/shotgunsoftware/tk-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shotgunsoftware/tk-core/labels{/name}","releases_url":"https://api.github.com/repos/shotgunsoftware/tk-core/releases{/id}","deployments_url":"https://api.github.com/repos/shotgunsoftware/tk-core/deployments","created_at":"2012-05-09T09:12:06Z","updated_at":"2016-09-08T07:11:16Z","pushed_at":"2016-09-16T11:57:20Z","git_url":"git://github.com/shotgunsoftware/tk-core.git","ssh_url":"git@github.com:shotgunsoftware/tk-core.git","clone_url":"https://github.com/shotgunsoftware/tk-core.git","svn_url":"https://github.com/shotgunsoftware/tk-core","homepage":"","size":39855,"stargazers_count":27,"watchers_count":27,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":23,"mirror_url":null,"open_issues_count":17,"forks":23,"open_issues":17,"watchers":27,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/shotgunsoftware/tk-core/pulls/337"},"html":{"href":"https://github.com/shotgunsoftware/tk-core/pull/337"},"issue":{"href":"https://api.github.com/repos/shotgunsoftware/tk-core/issues/337"},"comments":{"href":"https://api.github.com/repos/shotgunsoftware/tk-core/issues/337/comments"},"review_comments":{"href":"https://api.github.com/repos/shotgunsoftware/tk-core/pulls/337/comments"},"review_comment":{"href":"https://api.github.com/repos/shotgunsoftware/tk-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/shotgunsoftware/tk-core/pulls/337/commits"},"statuses":{"href":"https://api.github.com/repos/shotgunsoftware/tk-core/statuses/22657ee8f8d4a7aa30360b0b0d6c9e9221ff096f"}}}}
{"actor":{"display_login":"josh-t"}}