I have the same problem with python template substitution. If my python cgi uses a print statement for the recaptcha frame inside the script there's no problem. But I need to use a (python string) template for my html form since it's not practical to put longer print statements inside cgi scripts.
This code prints all the form fields EXCEPT recaptcha challenge and response:
form = cgi.FieldStorage()
fields = {}
def process_form(**kw):
form_list = ['recaptcha_challenge_field', 'recaptcha_response_field', 'Last_Name', 'First_Name']
fields = kw.get('fields', {}) # dict of form field names & values
errors = []
...
if form.getvalue('Submit'):
response = captcha.submit(
fields['recaptcha_challenge_field'],
fields['recaptcha_response_field'],
private_key,
remote_addr)
if response.error_code:
errors.append("display_recaptcha?error=%s"%response.error_code)
errors.append(fields['recaptcha_response_field'])
# check to see if form fields are processed
for field in fields:
print field, fields[field]
...
try:
t = Template(open(template_form).read())
print t.substitute(title_msg=title_msg +'<br/>'.join(errors), **fields)
This is very frustrating because it worked for python 2.4 and 2.5, but the same code fails to pass recaptcha challenge/response values in python 2.7. Is there a solution? Is there another group I should post this problem to?