Re: TimeConverter validator
Jorge Godoy <[email protected]>
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Organization | G2C Tech Consultoria Ltda. |
| Message-ID | <[email protected]> |
Ian Bicking <[email protected]> writes: > I think it preceded datetime.time (maybe). Nevertheless, it should > certainly accept those objects, and probably based on some option should > produce datetime.time objects as well (it shouldn't produce them by > default because that won't be backward compatible, though a subclass of > TimeConverter certainly could default to datetime.time). I see. :-) I agree with the default behaviour. If it is included with the standard validator I don't believe a subclass is needed. If a subclass is better -- I believe it is... -- then we don't have to worry with backwards compatibility. > Patches welcome (shouldn't be too hard, I think). It isn't too hard to convert the tuple to a datetime.time object: In [2]:from formencode.validators import TimeConverter In [3]:v = TimeConverter() In [4]:a = v.to_python('18:00') In [5]:a Out[5]:(18, 0) In [6]:type(a) Out[6]:<type 'tuple'> In [7]:from datetime import time In [8]:b = time(*a) In [9]:b Out[9]:datetime.time(18, 0) In [10]:type(b) Out[10]:<type 'datetime.time'> Should the patch only try using datetime.time or should it also try mx.DateTime? Just to remember, datetime is available in the standard library since Python 2.3 (so say the docs). I believe I can write the patch today if it is only targetted at datetime. -- 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