reddit/reddit — pull request #750 by buddydvd (2013-04-24 23:07:06+00:00)
Title: Fix unexpected captcha iden in response

This pull requests fixes two issues with regards to unexpected captcha identifier sent in API call responses. For clarity, I separated the fix for both issues into two commits.

----

**Issue 1: When a submission call succeeds, the server may attach an unexpected captcha identifier to the response.**

The reason why this happens is because `c.errors` contains all errors detected by `Validator`s (many of which are ignored by the controller methods). On the other hand, `form.has_error()` returns true if there exist errors that were explicitly set in controller methods with `has_errors(...)` and `set_error(...)`.

For example, when a link submission succeeds, `c.errors` contains the following values:

- `('NO_TEXT', 'extension')`
- `('NO_TEXT', 'text')`

while `form.has_error()` returns `False`.

----

**Issue 2: When a submission call fails for a user that doesn't need captcha, the server always attach an unexpected captcha identifier.**

The change avoids sending captcha iden for failed API calls by users that don't need it.