Re: String validator returning unicode
Jorge Godoy <[email protected]>
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Organization | G2C Tech Consultoria Ltda. |
| Message-ID | <[email protected]> |
Peter Russell <[email protected]> writes: > Hi, > > I'm not entirely sure if this is a bug, but the behaviour of the String > validator seems odd to me. > > If its to_python method is passed a unicode object it returns a unicode > object. This is a problem when using SQLObject, where if you try to > pass unicode objects into StringCols (reasonably thinking they are > strings, since they've been through a string validator), you get a > unicode decode error. > > I think the sensible behaviour for String would be to convert to str. > Is this sensible? And what would you do with characters that can't be represented in a single charset? The correct behavior to me would be to raise an exception when that happens... Or provide a way to do something like convert them to their equivalent numeric code, strip those chars, make them "?", etc. But it shouldn't silently pass by default. -- Jorge Godoy <[email protected]> ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642