Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.reload() fails if the previous request was a POST #74

Open
mgedmin opened this issue Jun 27, 2019 · 1 comment
Open

.reload() fails if the previous request was a POST #74

mgedmin opened this issue Jun 27, 2019 · 1 comment
Labels
compat Compatibility issues due to mechanize -> webtest migration in 5.0.0

Comments

@mgedmin
Copy link
Member

mgedmin commented Jun 27, 2019

I've seen variations on this, some of which end up in an error like

Failed example:
    manager.reload()
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python2.7/doctest.py", line 1315, in __run
        compileflags, 1) in test.globs
      File "<doctest invitations.txt[101]>", line 1, in <module>
        manager.reload()
      File "/home/mg/src/zopefoundation/zope.testbrowser/src/zope/testbrowser/browser.py", line 197, in reload
        resp = self.testapp.request(req)
      File "/home/mg/src/ivija/.tox/py27-latest/local/lib/python2.7/site-packages/webtest/app.py", line 581, in request
        req = url_or_req.copy()
      File "/home/mg/src/ivija/.tox/py27-latest/local/lib/python2.7/site-packages/webob/request.py", line 861, in copy
        self.make_body_seekable()
      File "/home/mg/src/ivija/.tox/py27-latest/local/lib/python2.7/site-packages/webob/request.py", line 929, in make_body_seekable
        self.copy_body()
      File "/home/mg/src/ivija/.tox/py27-latest/local/lib/python2.7/site-packages/webob/request.py", line 953, in copy_body
        data = input.read(min(todo, 65535))
      File "/home/mg/src/ivija/.tox/py27-latest/local/lib/python2.7/site-packages/webob/request.py", line 1544, in readinto
        "(%d more bytes were expected)" % (self.remaining,)
    DisconnectionError: The client disconnected while sending the body (79 more bytes were expected)

and some of which silently end up with a browser.contents of ''. (that was actually a different bug, see #75)

I get the impression that submitting a form and then calling reload() in the old mechanize-based testbrowser used to replay the last POST request as a GET to the same URL.

I don't think that's a good idea either, so what I propose instead is to have zope.testbrowser explicitly raise a BrowserStateError() if you try to reload a POST.

@mgedmin mgedmin added the compat Compatibility issues due to mechanize -> webtest migration in 5.0.0 label Jun 27, 2019
mgedmin added a commit that referenced this issue Jun 27, 2019
@mgedmin
Copy link
Member Author

mgedmin commented Jul 1, 2019

I get the impression that submitting a form and then calling reload() in the old mechanize-based testbrowser used to replay the last POST request as a GET to the same URL.

Looks like no, it was actually repeating the POST. And the new zope.testbrowser has a test to make sure .reload() repeats the POST, but it sometimes fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compat Compatibility issues due to mechanize -> webtest migration in 5.0.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant