{"action":"created","comment":{"url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/pulls/comments/122152862","pull_request_review_id":44241038,"id":122152862,"diff_hunk":"@@ -0,0 +1,330 @@\n+from Acquisition import aq_base\n+from App.ZApplication import ZApplicationWrapper\n+from ftw.testbrowser.drivers.utils import isolated\n+from ftw.testbrowser.drivers.utils import remembering_for_reload\n+from ftw.testbrowser.exceptions import BlankPage\n+from ftw.testbrowser.exceptions import RedirectLoopException\n+from ftw.testbrowser.interfaces import IDriver\n+from ftw.testbrowser.utils import copy_docs_from_interface\n+from requests.structures import CaseInsensitiveDict\n+from StringIO import StringIO\n+from urllib import unquote\n+from urlparse import urlparse\n+from zope.interface import implements\n+from ZPublisher.BaseRequest import RequestContainer\n+from ZPublisher.Iterators import IStreamIterator\n+from ZPublisher.Response import Response\n+from ZPublisher.Test import publish_module\n+import httplib\n+import requests\n+import sys\n+import Zope2\n+import ZPublisher\n+\n+\n+# from plone.testing._z2_testbrowser\n+class TestResponse(Response):\n+\n+    def setBody(self, body, title='', is_error=0, **kw):\n+        if IStreamIterator.providedBy(body):\n+            body = ''.join(body)\n+        Response.setBody(self, body, title, is_error, **kw)\n+\n+\n+class NoCommitTransactionsManagerWrapper(object):\n+    \"\"\"Wraps a Zope2.App.startup.TransactionsManager and patches\n+    Zope2.zpublisher_transactions_manager with a singleton instance.\n+\n+    The wrapper lives for the rest of the process duration since it\n+    is cached in the function argument default dict ``modules`` of the\n+    function ``ZPublisher.Publish.get_module_info``.\n+\n+    When the wrapper is activated with ``activate_wrapper`` it silently\n+    aborts all commit intents.\n+    When then transaction is beginning, we replace the ZApplicationWrapper\n+    object in the requests's PARENTS with an actual application root with\n+    the current connection in order to avoid a new connection to be created\n+    when the ZApplicationWrapper is traversed, since this would result in a\n+    reset of uncommitted state.\n+    \"\"\"\n+\n+    @classmethod\n+    def setup(klass):\n+        \"\"\"Make sure the wrapper is active and return the wrapper.\n+        May or may not create a new wrapper.\n+        \"\"\"\n+        if not isinstance(Zope2.zpublisher_transactions_manager, klass):\n+            Zope2.zpublisher_transactions_manager = klass(\n+                Zope2.zpublisher_transactions_manager)\n+\n+            modules_cache = ZPublisher.Publish.get_module_info.func_defaults[0]\n+            assert isinstance(modules_cache, dict), \\\n+                'get_module_info modules cache changed unexpectedly.'\n+            modules_cache.pop('Zope2', None)\n+            modules_cache.pop('Zope2.cgi', None)\n+\n+        return Zope2.zpublisher_transactions_manager\n+\n+    def __init__(self, wrapped):\n+        self.wrapped = wrapped\n+        self.active = False\n+        self.next_request = None\n+        self.current_app = None\n+\n+    def activate_wrapper(self, next_request, current_app):\n+        self.active = True\n+        self.next_request = next_request","path":"ftw/testbrowser/drivers/traversaldriver.py","position":null,"original_position":76,"commit_id":"47084f1e81c56f6412500acc41bb133ac5347db0","original_commit_id":"22df027ac1a5bdd20eb2db302165c246c50039fa","user":{"login":"jone","id":7469,"avatar_url":"https://avatars0.githubusercontent.com/u/7469?v=3","gravatar_id":"","url":"https://api.github.com/users/jone","html_url":"https://github.com/jone","followers_url":"https://api.github.com/users/jone/followers","following_url":"https://api.github.com/users/jone/following{/other_user}","gists_url":"https://api.github.com/users/jone/gists{/gist_id}","starred_url":"https://api.github.com/users/jone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jone/subscriptions","organizations_url":"https://api.github.com/users/jone/orgs","repos_url":"https://api.github.com/users/jone/repos","events_url":"https://api.github.com/users/jone/events{/privacy}","received_events_url":"https://api.github.com/users/jone/received_events","type":"User","site_admin":false},"body":"I have realized that this is actually a context manager and changed it accordingly.\r\nThis is now done in ``__call__``, I have added a docstring.","created_at":"2017-06-15T08:55:41Z","updated_at":"2017-06-15T08:55:41Z","html_url":"https://github.com/4teamwork/ftw.testbrowser/pull/54#discussion_r122152862","pull_request_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/pulls/54","_links":{"self":{"href":"https://api.github.com/repos/4teamwork/ftw.testbrowser/pulls/comments/122152862"},"html":{"href":"https://github.com/4teamwork/ftw.testbrowser/pull/54#discussion_r122152862"},"pull_request":{"href":"https://api.github.com/repos/4teamwork/ftw.testbrowser/pulls/54"}}},"pull_request":{"url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/pulls/54","id":125579885,"html_url":"https://github.com/4teamwork/ftw.testbrowser/pull/54","diff_url":"https://github.com/4teamwork/ftw.testbrowser/pull/54.diff","patch_url":"https://github.com/4teamwork/ftw.testbrowser/pull/54.patch","issue_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/issues/54","number":54,"state":"open","locked":false,"title":"Add traversal driver.","user":{"login":"jone","id":7469,"avatar_url":"https://avatars0.githubusercontent.com/u/7469?v=3","gravatar_id":"","url":"https://api.github.com/users/jone","html_url":"https://github.com/jone","followers_url":"https://api.github.com/users/jone/followers","following_url":"https://api.github.com/users/jone/following{/other_user}","gists_url":"https://api.github.com/users/jone/gists{/gist_id}","starred_url":"https://api.github.com/users/jone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jone/subscriptions","organizations_url":"https://api.github.com/users/jone/orgs","repos_url":"https://api.github.com/users/jone/repos","events_url":"https://api.github.com/users/jone/events{/privacy}","received_events_url":"https://api.github.com/users/jone/received_events","type":"User","site_admin":false},"body":"The traversal driver executes the requests by traversing internally in the same transaction and with the same connection as the test.\r\n\r\nThe advantage of the traversal driver is that it does not need uncommitted state to be committed, nor does it commit modifications happening in the request.\r\n\r\n// cc @4teamwork/gever @buchi @maethu ","created_at":"2017-06-14T12:10:33Z","updated_at":"2017-06-15T08:55:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aa017a216d12b365b33536986dc31e0d575f8217","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/pulls/54/commits","review_comments_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/pulls/54/comments","review_comment_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/pulls/comments{/number}","comments_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/issues/54/comments","statuses_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/statuses/47084f1e81c56f6412500acc41bb133ac5347db0","head":{"label":"4teamwork:jone-traverse-driver","ref":"jone-traverse-driver","sha":"47084f1e81c56f6412500acc41bb133ac5347db0","user":{"login":"4teamwork","id":681821,"avatar_url":"https://avatars1.githubusercontent.com/u/681821?v=3","gravatar_id":"","url":"https://api.github.com/users/4teamwork","html_url":"https://github.com/4teamwork","followers_url":"https://api.github.com/users/4teamwork/followers","following_url":"https://api.github.com/users/4teamwork/following{/other_user}","gists_url":"https://api.github.com/users/4teamwork/gists{/gist_id}","starred_url":"https://api.github.com/users/4teamwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4teamwork/subscriptions","organizations_url":"https://api.github.com/users/4teamwork/orgs","repos_url":"https://api.github.com/users/4teamwork/repos","events_url":"https://api.github.com/users/4teamwork/events{/privacy}","received_events_url":"https://api.github.com/users/4teamwork/received_events","type":"Organization","site_admin":false},"repo":{"id":13704983,"name":"ftw.testbrowser","full_name":"4teamwork/ftw.testbrowser","owner":{"login":"4teamwork","id":681821,"avatar_url":"https://avatars1.githubusercontent.com/u/681821?v=3","gravatar_id":"","url":"https://api.github.com/users/4teamwork","html_url":"https://github.com/4teamwork","followers_url":"https://api.github.com/users/4teamwork/followers","following_url":"https://api.github.com/users/4teamwork/following{/other_user}","gists_url":"https://api.github.com/users/4teamwork/gists{/gist_id}","starred_url":"https://api.github.com/users/4teamwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4teamwork/subscriptions","organizations_url":"https://api.github.com/users/4teamwork/orgs","repos_url":"https://api.github.com/users/4teamwork/repos","events_url":"https://api.github.com/users/4teamwork/events{/privacy}","received_events_url":"https://api.github.com/users/4teamwork/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/4teamwork/ftw.testbrowser","description":"A testing browser for Plone.","fork":false,"url":"https://api.github.com/repos/4teamwork/ftw.testbrowser","forks_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/forks","keys_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/teams","hooks_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/hooks","issue_events_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/issues/events{/number}","events_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/events","assignees_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/assignees{/user}","branches_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/branches{/branch}","tags_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/tags","blobs_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/git/refs{/sha}","trees_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/statuses/{sha}","languages_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/languages","stargazers_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/stargazers","contributors_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/contributors","subscribers_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/subscribers","subscription_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/subscription","commits_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/commits{/sha}","git_commits_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/git/commits{/sha}","comments_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/comments{/number}","issue_comment_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/issues/comments{/number}","contents_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/contents/{+path}","compare_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/merges","archive_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/downloads","issues_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/issues{/number}","pulls_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/pulls{/number}","milestones_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/milestones{/number}","notifications_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/labels{/name}","releases_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/releases{/id}","deployments_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/deployments","created_at":"2013-10-19T17:05:42Z","updated_at":"2017-04-28T13:06:23Z","pushed_at":"2017-06-15T08:51:43Z","git_url":"git://github.com/4teamwork/ftw.testbrowser.git","ssh_url":"git@github.com:4teamwork/ftw.testbrowser.git","clone_url":"https://github.com/4teamwork/ftw.testbrowser.git","svn_url":"https://github.com/4teamwork/ftw.testbrowser","homepage":"http://ftwtestbrowser.readthedocs.io/","size":464,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":3,"default_branch":"master"}},"base":{"label":"4teamwork:master","ref":"master","sha":"d47e9862a83d362880d273243f0c38251bb81b7e","user":{"login":"4teamwork","id":681821,"avatar_url":"https://avatars1.githubusercontent.com/u/681821?v=3","gravatar_id":"","url":"https://api.github.com/users/4teamwork","html_url":"https://github.com/4teamwork","followers_url":"https://api.github.com/users/4teamwork/followers","following_url":"https://api.github.com/users/4teamwork/following{/other_user}","gists_url":"https://api.github.com/users/4teamwork/gists{/gist_id}","starred_url":"https://api.github.com/users/4teamwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4teamwork/subscriptions","organizations_url":"https://api.github.com/users/4teamwork/orgs","repos_url":"https://api.github.com/users/4teamwork/repos","events_url":"https://api.github.com/users/4teamwork/events{/privacy}","received_events_url":"https://api.github.com/users/4teamwork/received_events","type":"Organization","site_admin":false},"repo":{"id":13704983,"name":"ftw.testbrowser","full_name":"4teamwork/ftw.testbrowser","owner":{"login":"4teamwork","id":681821,"avatar_url":"https://avatars1.githubusercontent.com/u/681821?v=3","gravatar_id":"","url":"https://api.github.com/users/4teamwork","html_url":"https://github.com/4teamwork","followers_url":"https://api.github.com/users/4teamwork/followers","following_url":"https://api.github.com/users/4teamwork/following{/other_user}","gists_url":"https://api.github.com/users/4teamwork/gists{/gist_id}","starred_url":"https://api.github.com/users/4teamwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4teamwork/subscriptions","organizations_url":"https://api.github.com/users/4teamwork/orgs","repos_url":"https://api.github.com/users/4teamwork/repos","events_url":"https://api.github.com/users/4teamwork/events{/privacy}","received_events_url":"https://api.github.com/users/4teamwork/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/4teamwork/ftw.testbrowser","description":"A testing browser for Plone.","fork":false,"url":"https://api.github.com/repos/4teamwork/ftw.testbrowser","forks_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/forks","keys_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/teams","hooks_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/hooks","issue_events_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/issues/events{/number}","events_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/events","assignees_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/assignees{/user}","branches_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/branches{/branch}","tags_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/tags","blobs_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/git/refs{/sha}","trees_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/statuses/{sha}","languages_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/languages","stargazers_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/stargazers","contributors_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/contributors","subscribers_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/subscribers","subscription_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/subscription","commits_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/commits{/sha}","git_commits_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/git/commits{/sha}","comments_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/comments{/number}","issue_comment_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/issues/comments{/number}","contents_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/contents/{+path}","compare_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/merges","archive_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/downloads","issues_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/issues{/number}","pulls_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/pulls{/number}","milestones_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/milestones{/number}","notifications_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/labels{/name}","releases_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/releases{/id}","deployments_url":"https://api.github.com/repos/4teamwork/ftw.testbrowser/deployments","created_at":"2013-10-19T17:05:42Z","updated_at":"2017-04-28T13:06:23Z","pushed_at":"2017-06-15T08:51:43Z","git_url":"git://github.com/4teamwork/ftw.testbrowser.git","ssh_url":"git@github.com:4teamwork/ftw.testbrowser.git","clone_url":"https://github.com/4teamwork/ftw.testbrowser.git","svn_url":"https://github.com/4teamwork/ftw.testbrowser","homepage":"http://ftwtestbrowser.readthedocs.io/","size":464,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/4teamwork/ftw.testbrowser/pulls/54"},"html":{"href":"https://github.com/4teamwork/ftw.testbrowser/pull/54"},"issue":{"href":"https://api.github.com/repos/4teamwork/ftw.testbrowser/issues/54"},"comments":{"href":"https://api.github.com/repos/4teamwork/ftw.testbrowser/issues/54/comments"},"review_comments":{"href":"https://api.github.com/repos/4teamwork/ftw.testbrowser/pulls/54/comments"},"review_comment":{"href":"https://api.github.com/repos/4teamwork/ftw.testbrowser/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/4teamwork/ftw.testbrowser/pulls/54/commits"},"statuses":{"href":"https://api.github.com/repos/4teamwork/ftw.testbrowser/statuses/47084f1e81c56f6412500acc41bb133ac5347db0"}}}}
{"actor":{"display_login":"jone"}}