Re: [SQLObject] Magic attribute and object ID problem
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Emmanuel G. <ega...@le...> - 2008-12-17 01:18:19
|
Hi Oleg, On Tue, Dec 16, 2008 at 02:54:26PM +0300, Oleg Broytmann wrote: > On Tue, Dec 16, 2008 at 12:50:46PM +1100, Emmanuel Galanos wrote: > > > Unfortunately self.id is not available until after the object is > > created. > > Certainly it is not available. But perhaps you want to set some values > without touching the id? For the magic attribute, I need a unique identifier so that the external data can reference the SQL object. The id column would appear to be the obvious choice as is seen in the example at: http://sqlobject.org/SQLObject.html#adding-magic-attributes-properties Ideally SQLObject would either determine the id before row insertion (e.g. in PostgreSQL select nextval('blah_id_seq');) or defer setting of magic attributes until after the row is inserted. I imagine that deferring the setting would be the easiest method with respect to database compatibility and would have better performance. What do you think ? Regards, Emmanuel |