Ticket #190 (closed defect: fixed)
FormEncode does not export the Invalid class
| Reported by: | sthurgood | Owned by: | anonymous |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.8a6 |
| Component: | TurboGears | Version: | 0.8 |
| Severity: | major | Keywords: | formencode invalid validator |
| Cc: |
Description
When using validators I get an exception from line 108 of controllers.py:
except turbogearsvalid.Invalid, error:
turbogears has no Invalid attribute. turbogearsvalid is turbogears.validators which contains:
from formencode.validators import *
validators.py generates all dynamically with:
for name, value in globals().items():
if isinstance(value, type) and issubclass(value, Validator):
__all__.append(name)
Which does not include the Invalid class, as it is neither an instance of a type, nor a subclass of Validator
I fixed this by adding
from formencode.validators import Invalid
To turbogears/validators.py
Change History
Note: See
TracTickets for help on using
tickets.
The Invalid exception is defined in formencode.api; the following fixes it for me (it's a slightly more direct route than going via formencode.validators):
Severity updated to "major" as this completely breaks validators in TurboGears 0.8a5 + FormEncode 0.4
Ticket #44 is a complementary issue.