[sqlalchemy] Re: Relation w/ declarative

2009-08-06 Thread werner
Allen, allen.fowler wrote: ... > > What is that __repr__ function doing exactly? Looks interesting. > It is really useful, and yes Michael comes up with beauties like this. Produces nice print output, i.e.: print 'after flush' print con print add Will give you: after flush Contact(address=

[sqlalchemy] Re: Relation w/ declarative

2009-08-06 Thread allen.fowler
On Aug 6, 4:59 am, Wichert Akkerman wrote: > On 8/6/09 09:30 , werner wrote: > > > IIRC correctly the __init__ section is only needed if you want to do: > > add = Address('an email address') > > > I never do this, i.e. I assign like this > > add = Address() > > add.email_address = 'an email add

[sqlalchemy] Re: Relation w/ declarative

2009-08-06 Thread allen.fowler
On Aug 6, 3:30 am, werner wrote: > I never do this, i.e. I assign like this > add = Address() > add.email_address = 'an email address'> In what way is the Address object > expected to be instantiated such > > that it receives the correct user id? > > You just do this and SA will take care of

[sqlalchemy] Re: Relation w/ declarative

2009-08-06 Thread Wichert Akkerman
On 8/6/09 09:30 , werner wrote: > IIRC correctly the __init__ section is only needed if you want to do: > add = Address('an email address') > > I never do this, i.e. I assign like this > add = Address() > add.email_address = 'an email address' You can also do this with the default declarative bas

[sqlalchemy] Re: Relation w/ declarative

2009-08-06 Thread werner
Hi, AF wrote: > Am starting to experiment with declarative base. > > In the code block at: > > http://www.sqlalchemy.org/docs/05/ormtutorial.html#building-a-relation > > Why does __init__() not contain any mention of the foreign key > "user_id"? > > As one normally does not manually set an id