On Wed, May 13, 2009 at 07:11:22PM +0000, Matthew Wilson wrote:
> Hi -- I wrote some code to add a TimedeltaCol type.  I only tested it in
> postgresql.

   Thank you!

> +def TimedeltaConverter(value, db):
> +    
> +    return """INTERVAL '%d days %d seconds'""" % \
> +        (value.days, value.seconds)
> +
> +registerConverter(datetime.timedelta, TimedeltaConverter)

   The syntax is only valid in Postgres, so it has to be protected:

def TimedeltaConverter(value, db):
    if db == 'postgres':
        return """INTERVAL '%d days %d seconds'""" % \
            (value.days, value.seconds)
    else:
        raise ValueError('TimedeltaCol is only implemented for Postgres')

> +class TimedeltaValidator(validators.Validator):
> +    def to_python(self, value, state):
> +        return value
> +
> +    def from_python(self, value, state):
> +        return value

   Why empty validator?

   IWBN to have a test also.

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            p...@phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to