{"action":"created","comment":{"url":"https://api.github.com/repos/django-oscar/django-oscar-api/pulls/comments/24707470","id":24707470,"diff_hunk":"@@ -110,3 +111,20 @@ def get_session(session_id, raise_on_create=False):\n             session.save(must_create=True)\n \n     return session\n+\n+\n+def i18n_path_regex():","path":"oscarapi/utils.py","position":12,"original_position":12,"commit_id":"1fa574e5b98fb4a529501df30917f1d18e57aece","original_commit_id":"1fa574e5b98fb4a529501df30917f1d18e57aece","user":{"login":"maerteijn","id":121401,"avatar_url":"https://avatars.githubusercontent.com/u/121401?v=3","gravatar_id":"","url":"https://api.github.com/users/maerteijn","html_url":"https://github.com/maerteijn","followers_url":"https://api.github.com/users/maerteijn/followers","following_url":"https://api.github.com/users/maerteijn/following{/other_user}","gists_url":"https://api.github.com/users/maerteijn/gists{/gist_id}","starred_url":"https://api.github.com/users/maerteijn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maerteijn/subscriptions","organizations_url":"https://api.github.com/users/maerteijn/orgs","repos_url":"https://api.github.com/users/maerteijn/repos","events_url":"https://api.github.com/users/maerteijn/events{/privacy}","received_events_url":"https://api.github.com/users/maerteijn/received_events","type":"User","site_admin":false},"body":"Like this?","created_at":"2015-02-13T23:58:44Z","updated_at":"2015-02-13T23:58:44Z","html_url":"https://github.com/django-oscar/django-oscar-api/pull/7#discussion_r24707470","pull_request_url":"https://api.github.com/repos/django-oscar/django-oscar-api/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/django-oscar/django-oscar-api/pulls/comments/24707470"},"html":{"href":"https://github.com/django-oscar/django-oscar-api/pull/7#discussion_r24707470"},"pull_request":{"href":"https://api.github.com/repos/django-oscar/django-oscar-api/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/django-oscar/django-oscar-api/pulls/7","id":29287184,"html_url":"https://github.com/django-oscar/django-oscar-api/pull/7","diff_url":"https://github.com/django-oscar/django-oscar-api/pull/7.diff","patch_url":"https://github.com/django-oscar/django-oscar-api/pull/7.patch","issue_url":"https://api.github.com/repos/django-oscar/django-oscar-api/issues/7","number":7,"state":"open","locked":false,"title":"Remove locale from url","user":{"login":"maerteijn","id":121401,"avatar_url":"https://avatars.githubusercontent.com/u/121401?v=3","gravatar_id":"","url":"https://api.github.com/users/maerteijn","html_url":"https://github.com/maerteijn","followers_url":"https://api.github.com/users/maerteijn/followers","following_url":"https://api.github.com/users/maerteijn/following{/other_user}","gists_url":"https://api.github.com/users/maerteijn/gists{/gist_id}","starred_url":"https://api.github.com/users/maerteijn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maerteijn/subscriptions","organizations_url":"https://api.github.com/users/maerteijn/orgs","repos_url":"https://api.github.com/users/maerteijn/repos","events_url":"https://api.github.com/users/maerteijn/events{/privacy}","received_events_url":"https://api.github.com/users/maerteijn/received_events","type":"User","site_admin":false},"body":"When i18n is enabled in Django it sometimes occures that `reverse('root-api')` returns an url including a different locale then the current locale. Why this happens is unknown, it's something in the i18n code in Django and it's really hard to reproduce.\r\n\r\nThe problem is that when it occurs, the `is_api_request()` call returns False, so the session which is build up by the `Session-Id` header is not resumed, instead a normal django session is initiated. When you retrieve your basket using the API you will get a different one as it cannot find it in your session.\r\n\r\nSee this debug log what happens:\r\n```\r\nDEBUG 2015-02-13 11:41:20,639 middleware >> NO API request -> path:/nl-nl/api/basket/ api_root:/fr-be/api/\r\nDEBUG 2015-02-13 11:41:20,639 middleware >> NO API request, using normal session middleware\r\nDEBUG 2015-02-13 11:41:20,652 abstract_models Session basket info:SID:ANON:shop-api.myshop.com:{cfa69238-4f46-47d6-9ed8-0f8a75e14eee} -> key:None contents:{}\r\n```\r\nThe session key will result in `None` so it won't return the correct basket.\r\n\r\nAs the locale is irrelevant to check if it's an api request, this code will remove the language from the url's prior to comparison.","created_at":"2015-02-13T18:27:55Z","updated_at":"2015-02-13T23:58:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"00069ced7be8bbd049e1a3b63f9d742fd39edf64","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/django-oscar/django-oscar-api/pulls/7/commits","review_comments_url":"https://api.github.com/repos/django-oscar/django-oscar-api/pulls/7/comments","review_comment_url":"https://api.github.com/repos/django-oscar/django-oscar-api/pulls/comments/{number}","comments_url":"https://api.github.com/repos/django-oscar/django-oscar-api/issues/7/comments","statuses_url":"https://api.github.com/repos/django-oscar/django-oscar-api/statuses/1fa574e5b98fb4a529501df30917f1d18e57aece","head":{"label":"django-oscar:remove-locale-from-url","ref":"remove-locale-from-url","sha":"1fa574e5b98fb4a529501df30917f1d18e57aece","user":{"login":"django-oscar","id":9057806,"avatar_url":"https://avatars.githubusercontent.com/u/9057806?v=3","gravatar_id":"","url":"https://api.github.com/users/django-oscar","html_url":"https://github.com/django-oscar","followers_url":"https://api.github.com/users/django-oscar/followers","following_url":"https://api.github.com/users/django-oscar/following{/other_user}","gists_url":"https://api.github.com/users/django-oscar/gists{/gist_id}","starred_url":"https://api.github.com/users/django-oscar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django-oscar/subscriptions","organizations_url":"https://api.github.com/users/django-oscar/orgs","repos_url":"https://api.github.com/users/django-oscar/repos","events_url":"https://api.github.com/users/django-oscar/events{/privacy}","received_events_url":"https://api.github.com/users/django-oscar/received_events","type":"Organization","site_admin":false},"repo":{"id":8760389,"name":"django-oscar-api","full_name":"django-oscar/django-oscar-api","owner":{"login":"django-oscar","id":9057806,"avatar_url":"https://avatars.githubusercontent.com/u/9057806?v=3","gravatar_id":"","url":"https://api.github.com/users/django-oscar","html_url":"https://github.com/django-oscar","followers_url":"https://api.github.com/users/django-oscar/followers","following_url":"https://api.github.com/users/django-oscar/following{/other_user}","gists_url":"https://api.github.com/users/django-oscar/gists{/gist_id}","starred_url":"https://api.github.com/users/django-oscar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django-oscar/subscriptions","organizations_url":"https://api.github.com/users/django-oscar/orgs","repos_url":"https://api.github.com/users/django-oscar/repos","events_url":"https://api.github.com/users/django-oscar/events{/privacy}","received_events_url":"https://api.github.com/users/django-oscar/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/django-oscar/django-oscar-api","description":"RESTful JSON API for django-oscar","fork":false,"url":"https://api.github.com/repos/django-oscar/django-oscar-api","forks_url":"https://api.github.com/repos/django-oscar/django-oscar-api/forks","keys_url":"https://api.github.com/repos/django-oscar/django-oscar-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/django-oscar/django-oscar-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/django-oscar/django-oscar-api/teams","hooks_url":"https://api.github.com/repos/django-oscar/django-oscar-api/hooks","issue_events_url":"https://api.github.com/repos/django-oscar/django-oscar-api/issues/events{/number}","events_url":"https://api.github.com/repos/django-oscar/django-oscar-api/events","assignees_url":"https://api.github.com/repos/django-oscar/django-oscar-api/assignees{/user}","branches_url":"https://api.github.com/repos/django-oscar/django-oscar-api/branches{/branch}","tags_url":"https://api.github.com/repos/django-oscar/django-oscar-api/tags","blobs_url":"https://api.github.com/repos/django-oscar/django-oscar-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/django-oscar/django-oscar-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/django-oscar/django-oscar-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/django-oscar/django-oscar-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/django-oscar/django-oscar-api/statuses/{sha}","languages_url":"https://api.github.com/repos/django-oscar/django-oscar-api/languages","stargazers_url":"https://api.github.com/repos/django-oscar/django-oscar-api/stargazers","contributors_url":"https://api.github.com/repos/django-oscar/django-oscar-api/contributors","subscribers_url":"https://api.github.com/repos/django-oscar/django-oscar-api/subscribers","subscription_url":"https://api.github.com/repos/django-oscar/django-oscar-api/subscription","commits_url":"https://api.github.com/repos/django-oscar/django-oscar-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/django-oscar/django-oscar-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/django-oscar/django-oscar-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/django-oscar/django-oscar-api/issues/comments/{number}","contents_url":"https://api.github.com/repos/django-oscar/django-oscar-api/contents/{+path}","compare_url":"https://api.github.com/repos/django-oscar/django-oscar-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/django-oscar/django-oscar-api/merges","archive_url":"https://api.github.com/repos/django-oscar/django-oscar-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/django-oscar/django-oscar-api/downloads","issues_url":"https://api.github.com/repos/django-oscar/django-oscar-api/issues{/number}","pulls_url":"https://api.github.com/repos/django-oscar/django-oscar-api/pulls{/number}","milestones_url":"https://api.github.com/repos/django-oscar/django-oscar-api/milestones{/number}","notifications_url":"https://api.github.com/repos/django-oscar/django-oscar-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/django-oscar/django-oscar-api/labels{/name}","releases_url":"https://api.github.com/repos/django-oscar/django-oscar-api/releases{/id}","created_at":"2013-03-13T20:05:58Z","updated_at":"2015-02-12T10:12:18Z","pushed_at":"2015-02-13T23:57:26Z","git_url":"git://github.com/django-oscar/django-oscar-api.git","ssh_url":"git@github.com:django-oscar/django-oscar-api.git","clone_url":"https://github.com/django-oscar/django-oscar-api.git","svn_url":"https://github.com/django-oscar/django-oscar-api","homepage":null,"size":486,"stargazers_count":14,"watchers_count":14,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":2,"forks":9,"open_issues":2,"watchers":14,"default_branch":"master"}},"base":{"label":"django-oscar:master","ref":"master","sha":"27d1d3e731cf370e018ea613aa56ce40ca3aab5e","user":{"login":"django-oscar","id":9057806,"avatar_url":"https://avatars.githubusercontent.com/u/9057806?v=3","gravatar_id":"","url":"https://api.github.com/users/django-oscar","html_url":"https://github.com/django-oscar","followers_url":"https://api.github.com/users/django-oscar/followers","following_url":"https://api.github.com/users/django-oscar/following{/other_user}","gists_url":"https://api.github.com/users/django-oscar/gists{/gist_id}","starred_url":"https://api.github.com/users/django-oscar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django-oscar/subscriptions","organizations_url":"https://api.github.com/users/django-oscar/orgs","repos_url":"https://api.github.com/users/django-oscar/repos","events_url":"https://api.github.com/users/django-oscar/events{/privacy}","received_events_url":"https://api.github.com/users/django-oscar/received_events","type":"Organization","site_admin":false},"repo":{"id":8760389,"name":"django-oscar-api","full_name":"django-oscar/django-oscar-api","owner":{"login":"django-oscar","id":9057806,"avatar_url":"https://avatars.githubusercontent.com/u/9057806?v=3","gravatar_id":"","url":"https://api.github.com/users/django-oscar","html_url":"https://github.com/django-oscar","followers_url":"https://api.github.com/users/django-oscar/followers","following_url":"https://api.github.com/users/django-oscar/following{/other_user}","gists_url":"https://api.github.com/users/django-oscar/gists{/gist_id}","starred_url":"https://api.github.com/users/django-oscar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django-oscar/subscriptions","organizations_url":"https://api.github.com/users/django-oscar/orgs","repos_url":"https://api.github.com/users/django-oscar/repos","events_url":"https://api.github.com/users/django-oscar/events{/privacy}","received_events_url":"https://api.github.com/users/django-oscar/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/django-oscar/django-oscar-api","description":"RESTful JSON API for django-oscar","fork":false,"url":"https://api.github.com/repos/django-oscar/django-oscar-api","forks_url":"https://api.github.com/repos/django-oscar/django-oscar-api/forks","keys_url":"https://api.github.com/repos/django-oscar/django-oscar-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/django-oscar/django-oscar-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/django-oscar/django-oscar-api/teams","hooks_url":"https://api.github.com/repos/django-oscar/django-oscar-api/hooks","issue_events_url":"https://api.github.com/repos/django-oscar/django-oscar-api/issues/events{/number}","events_url":"https://api.github.com/repos/django-oscar/django-oscar-api/events","assignees_url":"https://api.github.com/repos/django-oscar/django-oscar-api/assignees{/user}","branches_url":"https://api.github.com/repos/django-oscar/django-oscar-api/branches{/branch}","tags_url":"https://api.github.com/repos/django-oscar/django-oscar-api/tags","blobs_url":"https://api.github.com/repos/django-oscar/django-oscar-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/django-oscar/django-oscar-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/django-oscar/django-oscar-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/django-oscar/django-oscar-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/django-oscar/django-oscar-api/statuses/{sha}","languages_url":"https://api.github.com/repos/django-oscar/django-oscar-api/languages","stargazers_url":"https://api.github.com/repos/django-oscar/django-oscar-api/stargazers","contributors_url":"https://api.github.com/repos/django-oscar/django-oscar-api/contributors","subscribers_url":"https://api.github.com/repos/django-oscar/django-oscar-api/subscribers","subscription_url":"https://api.github.com/repos/django-oscar/django-oscar-api/subscription","commits_url":"https://api.github.com/repos/django-oscar/django-oscar-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/django-oscar/django-oscar-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/django-oscar/django-oscar-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/django-oscar/django-oscar-api/issues/comments/{number}","contents_url":"https://api.github.com/repos/django-oscar/django-oscar-api/contents/{+path}","compare_url":"https://api.github.com/repos/django-oscar/django-oscar-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/django-oscar/django-oscar-api/merges","archive_url":"https://api.github.com/repos/django-oscar/django-oscar-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/django-oscar/django-oscar-api/downloads","issues_url":"https://api.github.com/repos/django-oscar/django-oscar-api/issues{/number}","pulls_url":"https://api.github.com/repos/django-oscar/django-oscar-api/pulls{/number}","milestones_url":"https://api.github.com/repos/django-oscar/django-oscar-api/milestones{/number}","notifications_url":"https://api.github.com/repos/django-oscar/django-oscar-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/django-oscar/django-oscar-api/labels{/name}","releases_url":"https://api.github.com/repos/django-oscar/django-oscar-api/releases{/id}","created_at":"2013-03-13T20:05:58Z","updated_at":"2015-02-12T10:12:18Z","pushed_at":"2015-02-13T23:57:26Z","git_url":"git://github.com/django-oscar/django-oscar-api.git","ssh_url":"git@github.com:django-oscar/django-oscar-api.git","clone_url":"https://github.com/django-oscar/django-oscar-api.git","svn_url":"https://github.com/django-oscar/django-oscar-api","homepage":null,"size":486,"stargazers_count":14,"watchers_count":14,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":2,"forks":9,"open_issues":2,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/django-oscar/django-oscar-api/pulls/7"},"html":{"href":"https://github.com/django-oscar/django-oscar-api/pull/7"},"issue":{"href":"https://api.github.com/repos/django-oscar/django-oscar-api/issues/7"},"comments":{"href":"https://api.github.com/repos/django-oscar/django-oscar-api/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/django-oscar/django-oscar-api/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/django-oscar/django-oscar-api/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/django-oscar/django-oscar-api/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/django-oscar/django-oscar-api/statuses/1fa574e5b98fb4a529501df30917f1d18e57aece"}}}}