Am 16.05.2010 05:18 schrieb Eric:
Trying to use the above in a TG2.1b2 project and am getting
"AttributeError: 'function' object has no attribute 'message'". I
Googled around and don't find any comments about problems nor do I see
any bugs against USPostalCode in the BitBucket repository for
FormEncode.
I'm using it in a TableForm:
TextField('user_zip', size = 9, maxlength = 12, label_text = 'Zip
Code:* ', validator = USPostalCode)
USPostalCode is not a class as most other validators, but a function;
you need to call it to get an actual validator instance.
Also, tw.forms.validators does a "from formencode.validators import *"
and in formencode.validators.py I see:
def PostalCode(*kw, **kwargs):
warnings.warn("please use formencode.national.USPostalCode",
DeprecationWarning, stacklevel=2)
from formencode.national import USPostalCode
return USPostalCode(*kw, **kwargs)
so why does "tw.forms.validators import PostalCode" fail?
Because formencode.validators only defines, but does not export
PostalCode with __all__, so tw.forms.validators does not import it.
Anyway, it's deprecated and you shouldn't use it.
-- Christoph
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.