Hi Oleg,

Oleg Broytmann wrote:
> On Wed, Jun 13, 2007 at 11:16:14AM +0200, F.A. Pinkse wrote:
>> class Birthday(sqlobject.SQLObject):
>>      date = sqlobject.DateTimeCol(default=mx.DateTime.now())
> 
>    Calling now() means the default will be calculated by Python once at the
> class creation time (usually during import). You certainly want
> 
>      date = sqlobject.DateTimeCol(default=mx.DateTime.now)
> 
>    This way Python passes to SQLObject a callable, and SQLObject will call
> it at a row creation time.
> 
>> Now, I have all the date calculations available but...
>> how do I do my distinct value lookup on day, month and year?
> 
>    Using date/time functions that are provided by the database backend.
> 
> Oleg.

Thanks for your remark. You are right about the timestamp.
I do not need this timestamp but it came up as a fix in my early stages 
for an error message when I used: [ I think it needed something in the ()]

from DateTime import DateTime
and in my class:

date=DateTimeCol()


Now that I have added:

from mx import DateTime
if mxdatetime_available:
     col.default_datetime_implementation = MXDATETIME_IMPLEMENTATION

this error does not show up.

As a result of your remark I have cleaned my code to:

class Birthday(sqlobject.SQLObject):
     date = DateTimeCol()



Ok I have to read the backend manual for that.
To see what the benefits are.

Frans.




-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to