Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #190 (closed defect: fixed)

Opened 11 years ago

Last modified 10 years ago

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

comment:1 Changed 11 years ago by nic at bellamy dot co dot nz

  • Keywords validator added
  • Severity changed from normal to major

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):

--- validators.py.orig  2005-12-23 10:04:00.000000000 +1300
+++ validators.py       2005-12-23 10:02:06.000000000 +1300
@@ -4,3 +4,4 @@
 common validation routines are available here."""
 
 from formencode.validators import *
+from formencode.api import Invalid

Severity updated to "major" as this completely breaks validators in TurboGears 0.8a5 + FormEncode 0.4

Ticket #44 is a complementary issue.

comment:2 Changed 11 years ago by kevin

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone set to 0.8a6
Note: See TracTickets for help on using tickets.