On Tue, Feb 1, 2011 at 1:24 PM, Oleg Broytman <p...@phdru.name> wrote:
> On Tue, Feb 01, 2011 at 09:13:35PM +0300, Oleg Broytman wrote:
>> def DateTimeConverter(value, db):
>>     return "'%s'" % value.isoformat
>
>   Oops, sorry, a bug:
>
>    return "'%s'" % value.isoformat()
>
>>
>> registerConverter(datetime.datetime, DateTimeConverter)

Thank you as always Oleg for your prompt reply.

I will give this a try, meanwhile I have created my own column type:

--
class ISO8601Validator(validators.Validator):
   def from_python(self, value, state):
       if value is not None:
           value = value.strftime('%Y-%m-%d %H:%M:%S.%f')
       return value

   def to_python(self, value, state):
       if value is not None:
           value = datetime.datetime.strptime(value, '%Y-%m-%d %H:%M:%S.%f')
       return value

class SOISO8601Col(SOStringCol):
   def createValidators(self):
       return [ISO8601Validator()] + \
           super(SOISO8601Col, self).createValidators()

class ISO8601Col(StringCol):
   baseClass = SOISO8601Col
--

This seems to work for me. Will registering a converter work both
ways? i.e. the value is transformed to string for storage and back
again for retrieval?

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to