[sqlalchemy] Re: problem with backref

2006-12-24 Thread Manlio Perillo
Michael Bayer ha scritto: Please, can you quote my original message? Google does not send me back the messages I post. dont access the unloaded b attribute on o unless it is still attached to its session. when you sess.close(), o is no longer attached to a session. Ok. I usually call

[sqlalchemy] Re: problem with backref

2006-12-23 Thread Manlio Perillo
Michael Bayer ha scritto: the original mapping essentially expressed this relationship: A -- cascade=all, delete-orphan -- B in both directions. What that means is, there cannot be an A with no B in the database, and there cannot be a B with no A in the database, i.e. its either A-B or

[sqlalchemy] Re: problem with backref

2006-12-23 Thread Michael Bayer
dont access the unloaded b attribute on o unless it is still attached to its session. when you sess.close(), o is no longer attached to a session. also, dont say del o.b, or insure that you reassign a blank list to o.b. before accessing it again. the del operation deletes the list-based

[sqlalchemy] Re: problem with backref

2006-12-23 Thread Michael Bayer
im sorry, i meant a scalar value of None, not a blank list,since you have uselist=False. Assign None to o.b instead of saying del o.b. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to

[sqlalchemy] Re: problem with backref

2006-12-21 Thread Manlio Perillo
Michael Bayer ha scritto: the original mapping essentially expressed this relationship: A -- cascade=all, delete-orphan -- B in both directions. What that means is, there cannot be an A with no B in the database, and there cannot be a B with no A in the database, i.e. its either A-B or

[sqlalchemy] Re: problem with backref

2006-12-21 Thread Manlio Perillo
Alan Franzoni ha scritto: The problem is that it requires the explicit use of the session. In my case this means that I can not delete the object inside a method of my class. class A(object): def enableB(enable=True): if enable: self.b = B(...)

[sqlalchemy] Re: problem with backref

2006-12-21 Thread Alan Franzoni
A better solution is to do sess = object_session(self) That's wonderful and I didn't know about it! Finally I'll give up passing session around my code! Thanks! -- Alan Franzoni [EMAIL PROTECTED] - Togli .xyz dalla mia email per contattarmi. Remove .xyz from my address in order to contact

[sqlalchemy] Re: problem with backref

2006-12-20 Thread Manlio Perillo
Manlio Perillo ha scritto: Hi, I have a strange (for me) problem with backref. SQLAlchemy version is 0.3.1-1 on Debian Etch. Here is the code: [...] from sqlalchemy import * trans = conn.begin() sess = create_session() sess.update(o) print o.b.z del o.b A

[sqlalchemy] Re: problem with backref

2006-12-20 Thread Alan Franzoni
[italian mode] Come va Manlio? Ci sente anche qui alla fine :-) io per la fine dell'anno dovrei riuscire a finire il progetto su cui sto lavorando e potrĂ² riprendere finalmente il mio lavoro anche con python.it! [/italian mode] 1st: In order to use a transaction with a pre-existent connection,

[sqlalchemy] Re: problem with backref

2006-12-20 Thread Manlio Perillo
Alan Franzoni ha scritto: [italian mode] Come va Manlio? Ci sente anche qui alla fine :-) io per la fine dell'anno dovrei riuscire a finire il progetto su cui sto lavorando e potrĂ² riprendere finalmente il mio lavoro anche con python.it http://python.it! [/italian mode] Hi Alan! 1st:

[sqlalchemy] Re: problem with backref

2006-12-20 Thread Alan Franzoni
The problem is that it requires the explicit use of the session. In my case this means that I can not delete the object inside a method of my class. class A(object): def enableB(enable=True): if enable: self.b = B(...) else: del self.b Not a big problem,

[sqlalchemy] Re: problem with backref

2006-12-20 Thread Michael Bayer
the original mapping essentially expressed this relationship: A -- cascade=all, delete-orphan -- B in both directions. What that means is, there cannot be an A with no B in the database, and there cannot be a B with no A in the database, i.e. its either A-B or both will be deleted. its