On Mon, Nov 27, 2006 at 07:04:33PM +0100, Diez B. Roggisch wrote:
> class User(SQLObjec):
> ...
>
> def _init(self, *args, **kwargs):
> if <the_table_row_is_created>:
> co_object = CoObject(userID=self.id)
> return super(User, self)._init(*args, **kwargs)
>
> This will ensure there is a CoObject whenever there is a User.
_init() is called during creation, so you can be sure the row has not
been inserted into the DB yet, and there is no is. You need to change the
order of operations:
def _init(self, *args, **kwargs):
super(User, self)._init(*args, **kwargs) # Perform INSERT and get
the id
co_object = CoObject(userID=self.id)
_init() really is the best method to override for INSERT, but there is
no single method to override for UPDATEs...
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss