I am writing a function for some existing python code that will be passed a Mechanize browser object as a parameter.
I fill in some details in a form in the browser, and
It's been a while since I've written for python, but I think I have a workaround for your problem. Try this method:
import requests
except Mechanize.HTTPError:
while true: ## DANGER ##
## You will need to format and/or decode the POST for your form
response = requests.post('http://yourwebsite.com/formlink', data=None, json=None)
## If the server will accept JSON formatting, this becomes trivial
if response.status_code == accepted_code: break
You can find documentation about the requests library here. I personally think that requests is better for your case than mechanize... but it does require a little more overhead from you in that you need to break down the submission to raw POST using some kind of RESTful interceptor in your browser.
Ultimately though, by passing in br you are restricting yourself to the way that mechanize handles browser states on br.submit().