[SQLObject] date time column default now()
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Brian R. <br...@se...> - 2004-12-13 22:08:56
|
I need help using SQLObject. I am trying to override a column attribute without actually sending an argument. Is there a way I can get a time stamp functionality out of my date time column default? ... from mx.DateTime import * class table(SQLObject): timestamp = DateTimeCol(default=now()) ... The problem I am having is that the stamp fills in at the time when the object was initialized, not when a new row is added. This is the expected behavior. I was thinking the fix was adding something like: ... def _set_timestamp(self): return now() ... but, I get: "_set_timestamp() takes exactly 1 argument (2 given)" After removing the default, I also tried: ... def _set_timestamp(self): self._SO_set_timestamp(now()) ... but, I get: "did not get expected keyword argument 'timestamp'" I see in the manual where I can pass a value to these and then do something with this value. However, I would much rather not pass anything and get a time stamp in each row, once when created and maybe in a separate field once when updated. Any help, much appreciated. |