It turns out that the thing that looked like a date time string was
actually a DateTimeType object which is not the same thing asn an
mx.DateTime or a datetime.datetime.

So I monkeypatched the to_python script like this:

def to_python(self, value, state):
    if value is None:
        return None
    if isinstance(value, (datetime.datetime, datetime.date,
datetime.time, sqlbuilder.SQLExpression)):
        return value
    try:
        try:
            stime = time.strptime(value, self.format)
        except Exception, e:
############ HACK HERE ->
            stime =  ( value.year, value.month, value.day, value.hour,
value.minute, value.second, 0, 1, -1 )
    except:
        import pdb
        pdb.set_trace()
        
        raise validators.Invalid("expected an date/time string of the
'%s' format in the DateTimeCol '%s', got %s %r instead" % \
            (self.format, self.name, type(value), value), value, state)
    return datetime.datetime(*stime[:7])


Salim Fadhley 
Morgan Stanley | Fixed Income
20 Cabot Square | Canary Wharf | Floor 02
London, E14 4QW
Phone: +44 20 7677-7029
Mobile: +44 79737-10574
[EMAIL PROTECTED]
 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Fadhley, Salim (FID)
> Sent: 25 May 2006 17:04
> To: [email protected]
> Subject: RE: [SQLObject] That date validator bug...
> 
> That value came from sybase!
> 
> Look at the function to_python in col.py - it turns whatever 
> data format the DB uses to represent a date into a datetime 
> object. It works fine as long as the DB ises ISOFormat. If 
> for some reason the DB is misconfigured then it fails.
> 
> Sal
> 
> 
> Salim Fadhley
> Morgan Stanley | Fixed Income
> 20 Cabot Square | Canary Wharf | Floor 02 London, E14 4QW
> Phone: +44 20 7677-7029
> Mobile: +44 79737-10574
> [EMAIL PROTECTED]
>  
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] 
> > [mailto:[EMAIL PROTECTED] On 
> > Behalf Of Oleg Broytmann
> > Sent: 25 May 2006 16:53
> > To: [email protected]
> > Subject: Re: [SQLObject] That date validator bug...
> > 
> > On Thu, May 25, 2006 at 04:41:37PM +0100, Fadhley, Salim 
> (FID) wrote:
> > > (Pdb) value
> > > 'Jun 20 2007 12:00AM'
> > > (Pdb)
> > 
> >    Where the value came from?
> > 
> > Oleg.
> > -- 
> >      Oleg Broytmann            http://phd.pp.ru/            
> > [EMAIL PROTECTED]
> >            Programmers don't die, they just GOSUB without RETURN.
> > 
> > 
> > -------------------------------------------------------
> > All the advantages of Linux Managed Hosting--Without the Cost 
> > and Risk!
> > Fully trained technicians. The highest number of Red Hat 
> > certifications in the hosting industry. Fanatical Support. 
> > Click to learn more
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&;
> > dat=121642
> > _______________________________________________
> > sqlobject-discuss mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
> >
> --------------------------------------------------------
> 
> This is not an offer (or solicitation of an offer) to 
> buy/sell the securities/instruments mentioned or an official 
> confirmation.  Morgan Stanley may deal as principal in or own 
> or act as market maker for securities/instruments mentioned 
> or may advise the issuers.  This is not research and is not 
> from MS Research but it may refer to a research 
> analyst/research report.  Unless indicated, these views are 
> the author's and may differ from those of Morgan Stanley 
> research or others in the Firm.  We do not represent this is 
> accurate or complete and we may not update this.  Past 
> performance is not indicative of future returns.  For 
> additional information, research reports and important 
> disclosures, contact me or see 
> https://secure.ms.com/servlet/cls.  You should not use e-mail 
> to request, authorize or effect the purchase or sale of any 
> security or instrument, to send transfer instructions, or to 
> effect any other transactions.  We cannot guarantee that any 
> such requests received via e-mail will be processed in a 
> timely manner.  This communication is solely for the 
> addressee(s) and may contain confidential information.  We do 
> not waive confidentiality by mistransmission.  Contact me if 
> you do not wish to receive these communications.  In the UK, 
> this communication is directed in the UK to those persons who 
> are market counterparties or intermediate customers (as 
> defined in the UK Financial Services Authority's rules).
> 
> 
> -------------------------------------------------------
> All the advantages of Linux Managed Hosting--Without the Cost 
> and Risk!
> Fully trained technicians. The highest number of Red Hat 
> certifications in
> the hosting industry. Fanatical Support. Click to learn more
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid7521&bid$8729&dat1642
> _______________________________________________
> sqlobject-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
>
--------------------------------------------------------

This is not an offer (or solicitation of an offer) to buy/sell the 
securities/instruments mentioned or an official confirmation.  Morgan Stanley 
may deal as principal in or own or act as market maker for 
securities/instruments mentioned or may advise the issuers.  This is not 
research and is not from MS Research but it may refer to a research 
analyst/research report.  Unless indicated, these views are the author's and 
may differ from those of Morgan Stanley research or others in the Firm.  We do 
not represent this is accurate or complete and we may not update this.  Past 
performance is not indicative of future returns.  For additional information, 
research reports and important disclosures, contact me or see 
https://secure.ms.com/servlet/cls.  You should not use e-mail to request, 
authorize or effect the purchase or sale of any security or instrument, to send 
transfer instructions, or to effect any other transactions.  We cannot 
guarantee that any such requests received via e-mail will be processed in a 
timely manner.  This communication is solely for the addressee(s) and may 
contain confidential information.  We do not waive confidentiality by 
mistransmission.  Contact me if you do not wish to receive these 
communications.  In the UK, this communication is directed in the UK to those 
persons who are market counterparties or intermediate customers (as defined in 
the UK Financial Services Authority's rules).


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid7521&bid$8729&dat1642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to