Re: [SQLObject] Overriding new()..._SO_new()?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2003-10-10 21:08:56
|
On Friday, October 10, 2003, at 03:18 PM, Brad Bollenbach wrote: > On Friday, October 10, 2003, at 11:23 AM, Ian Bicking wrote: >>> Am I missing a way in which this can be done, or should SQLObject >>> have an _SO_new? >> >> You can override new() just like it is. (Though number 1 can >> probably be handled with a column default) > > Then what method do I call to access the "original" new once I've done > the overriding? When overriding columns, I'd just use the _SO_'s, but > when overriding new, it's unclear (to me, at least.) _SO_get_colName is an exception, because the SQLObject class doesn't implement methods for your columns. But SQLObject implements new(), so you can call SQLObject.new(cls, **kw) (or use super()). > Also, I don't see how using a column default will be able to default a DateTimeCol > to be the time at which the row was created, but in any case, I still want to > override new for at least the problem of wanting to instantiate a Transaction when > a Refund/Purchase/ChargeBack/whatever is instantiated. You can use SQLBuilder.const.NOW(), which will put 'NOW()' into the insert, or you can have a default value of DateTime.now -- functions and methods will be called when an object is inserted, so if the default is DateTime.now then DateTime.now() will be inserted. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |