[SQLObject] Re: Adding DB auto-timestamping to DateTimeCol
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Chris G. <ch...@il...> - 2004-08-14 18:16:17
|
On 30 Jul 2004, Mike Watkins said: > class Test(SQLObject): > foo=StrCol(length=20, default=None) > creation_date=DateTimeCol(default=None) > > When creating new Test objects, I do not want creation_date to be set > to null; I want the database to look after setting defaults. For the > time being I am passing a function > > creation_date=DateTimeCol(default=date.now) > > but that doesn't truly resolve the issue for me as I'd prefer to have > the database (postgres) deal with the time stamps. This makes it > easier to coexist with other apps or sql scripts directly manipulating > the DB. That's a good point. With a cluster of machines making calls to one central database, the date.now() could return a different time depending on which machine the code was being run on. And, as you said, it's better to let the DB do the timestamping when you're mixing SQLObject with other non-SQLObject apps that also use the DB. I think we should fix this. How about adding a boolean to the DateTimeCol class' constructor, like this: timestamp = DateTimeCol(autoTimestamp=True) That could work. Is "autoTimestamp" a keyword people are familiar with? :) |